码迷,mamicode.com
首页 > 其他好文 > 详细

UIPickerView

时间:2015-12-18 21:26:07      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:

 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];

UIPickerView

标签:

原文地址:http://www.cnblogs.com/linxiu-0925/p/5058153.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!