您的位置:首页 > 产品设计 > UI/UE

UIPickerView

2015-12-18 20:27 567 查看
6.16 UIPickerView

6.16.1 UIPickerViewDataSource
// 返回列数

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
//返回每列的行数

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:
(NSInteger)component;

6.16.2 UIPickerViewDelegate
// 返回数据

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row
forComponent:(NSInteger)component;

// 返回列宽度

- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:
(NSInteger)component;

//返回行高度

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:
(NSInteger)component;

组件_UIPickerView

<UIPickerViewDataSource, UIPickerViewDelegate>

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView //有几列

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component //每一列行数

[pickerView reloadComponent:1]; //刷新数据

/第component列第row行显示什么字符串内容

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component

//每当选择一行就会调用

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

/ 第component列第row行显示什么样的UIView,用自定义视图填充选择器的内容,view参数是用来性能优化的

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
// 返回第component列每一行的高度

- (CGFloat)pickerView:rowHeightForComponent:

/手码自定义PickerView时,需要指定显示选择指示器属性

[picker setShowsSelectionIndicator:YES];

/ 初始化Picker的选项

[picker selectRow:8 inComponent:0 animated:YES];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: