iOS UIPickerView


   * NSObject
   * UIResponder
   * UIView
   * UIPickerView

UIPickerView只有三个高度, heights for UIPickerView (162.0, 180.0 and 216.0)

- (NSInteger)numberOfRowsInComponent:(NSInteger)component   

组件的行数,默认值为0
- (CGSize)rowSizeForComponent:(NSInteger)component

组件的行大小(宽高)
- (CGFloat)pickerView:(UIPickerView *)pickerView
    widthForComponent:(NSInteger)component

组件的行宽
- (CGFloat)pickerView:(UIPickerView *)pickerView
rowHeightForComponent:(NSInteger)component

组件的行高
- (void)reloadAllComponents

重新加载所有组件的数据
- (void)reloadComponent:(NSInteger)component

重新加载指定组件的数据
- (void)selectRow:(NSInteger)row
      inComponent:(NSInteger)component
         animated:(BOOL)animated

选中某组件一行时的效果
- (NSInteger)selectedRowInComponent:(NSInteger)component

组件选中的行,如果没有选中,返回-1
- (UIView *)viewForRow:(NSInteger)row
          forComponent:(NSInteger)component

组件每行的视图,若指定行不可见或代理没有执行,返回0
@property(nonatomic) BOOL showsSelectionIndicator

是否显示指定行


delegate方法
//设置列宽和行高
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component;
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component;

//设置行标题
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
//
- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:
(NSInteger)row forComponent:(NSInteger)component NS_AVAILABLE_IOS(6_0); // attributed title is favored if both methods are implemented
//设置行视图
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view;
//选中行
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;

datasource方法
// 显示的行数
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
// 特定组件返回的行数
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值