UIPickerView的使用
来源:互联网 发布:乐视利润造假 知乎 编辑:程序博客网 时间:2024/04/28 12:51
代理方法
<UIPickerViewDataSource,UIPickerViewDelegate>
初始化
self.selectPicker.delegate = self;
self.selectPicker.dataSource = self;
self.selectPicker.frame = CGRectMake(0, 480, 320, 216) ;
代理方法
显示pickerview的components的个数
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
显示每个components的rows
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return [pickerArray count];
}
//显示每一行的title
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
return [pickerArray objectAtIndex:row];
}
1 UIPickerView
选择器
// 设置picker的数据源和代理,目的是将来为了调用协议方法
picker.dataSource = self;
picker.delegate = self;
// 设置显示中间的那两条线(选择指示器)
picker.showsSelectionIndicator = YES;
#pragma mark 标记
2 协议方法分为两种 必须实现的协议方法 @required
可选择的协议方法 @optional
3 // 获取两列中已经选择的行号
_firstRow = [pickerView selectedRowInComponent:0];
_secondRow = [pickerView selectedRowInComponent:1];
// 指定显示某列某行
[_picker selectRow:1 inComponent:0 animated:YES];
[_picker selectRow:1 inComponent:1 animated:YES];
重新加载(刷新) 所有 的 列
reloadAllComponents 会重新的调用pickerView的所有的与pickerView构建和显示相关的协议方法。
[_picker reloadAllComponents];
指定刷新某列
[_picker reloadComponent:0];
- UIPickerView 的使用
- UIPickerView的使用
- UIPickerView 的使用
- UIPickerView的使用
- UIPickerView的使用
- UIPickerView的使用
- UIPickerView的使用
- UIPickerView的使用
- UIPickerView控件的使用
- UIPickerView的简单使用
- iOS UIPickerView的使用
- UIPickerView的简单使用
- UIPickerView的使用
- UIPickerView的使用
- UIPickerView的使用
- UIPickerView的使用
- UIpickerView的使用
- UIPickerView的使用
- Linux-----Ubuntu设置开机启动模式
- 杭电oj数学题-1
- C++ 编程个人总结
- Basically Speaking
- [网络流24题] 16 数字梯形(最大权不相交路径 ,最小费用最大流)
- UIPickerView的使用
- iOS 网络开发NSURLConnection——使用代理方法发送异步请求
- Objective-C基础知识点
- 经典mysql语句
- 数据库索引的作用和优点缺点
- Java-2-类
- 有关Html页面节点的简单理解
- 单片机模拟spi通信
- 黑马程序员-[OC]学习之旅-对象和类