博客> UIPickerView的用法
UIPickerView的用法
2017-12-12 19:32 评论:0 阅读:86 进击的可乐SAMA

1.创建UIPickerView


//首先在所在的类中继承协议
UIPickerView * pikerView = [[UIPickerView alloc] iniiWithFrame:CGRectMake(n,n,n,n)];
pickerView.delegate = self;
pickerView.dataSource = self;

2.UIPickerView的代理方法


//1.返回列数
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
}
//2.返回每一列的行数
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
}
//3.返回每一行的视图
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
    UILabel * label = (UILabel *)view;
}
//4.点击每一行的事件
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
}
//5.返回每一行的高度
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component{
}
//6.返回每一行的title
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
}

3.其他方法


//刷新某一组
[pickerView reloadComponent:n];
//刷新全部
[pickerView reloadAllComponents];
收藏
0
sina weixin mail 回到顶部