首页 > 移动平台 > 详细

iOS开发之UIPickerView

时间:2015-08-31 21:28:51      阅读:289      评论:0      收藏:0      [点我收藏+]

1、使用方法

UIPickerView使用和UITableView大致类似。首先设置ViewController为数据源,然后遵守数据源协议< UIPickerViewDataRecouce>,之后实现协议中的方法:

一共有多少列:

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)

pickerView;

 

component列显示多少行:

- (NSInteger)pickerView:(UIPickerView *)pickerView

 numberOfRowsInComponent:(NSInteger)component;

 

上面只能设置UIPickerView有多少行、多少列,不能设置数据,如果要显示数据,必须要设置ViewController为UIPickerView的代理,遵守代理协议<UIPickerViewDelegate>,然后实现代理中的方法:

component列的第row行显示什么文字:

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:

(NSInteger)row forComponent:(NSInteger)component;

 

component列第row行显示怎样的view(内容)

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:

(NSInteger)row forComponent:(NSInteger)component reusingView:

(UIView *)view;

 

选中了pickerView的第component列第row

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:

(NSInteger)row inComponent:(NSInteger)component

iOS开发之UIPickerView

原文:http://www.cnblogs.com/lifengfneg/p/4773873.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!