UIPickerView 用法
UIPickerView 用法
两个代理
UIPickerViewDelegate
UIPickerViewDataSource
// returns the view provided by the delegate via pickerView:viewForRow:forComponent:reusingView:
// or nil if the row/component is not visible or the delegate does not implement
// pickerView:viewForRow:forComponent:reusingView:
//返回component列,row行的UIView,这里只有在定制情况下才有效,其他情况返回nil
- (UIView *)viewForRow:(NSInteger)row forComponent:(NSInteger)component;
// Reloading whole view or single component
//重装整个UIPickerView所有列和指定列的数据
- (void)reloadAllComponents;
- (void)reloadComponent:(NSInteger)component;
// selection. in this case, it means showing the appropriate row in the middle
- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated; // scrolls the specified row to center.
- (NSInteger)selectedRowInComponent:(NSInteger)component; // returns selected row. -1 if nothing selected
@protocol UIPickerViewDataSource<NSObject>
@required
// returns the number of 'columns' to display.
//返回总共有几列
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
// returns the # of rows in each component..
//返回指定列有几行
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
@end
@protocol UIPickerViewDelegate<NSObject>
@optional
// returns width of column and height of row for each component.
//返回指定列的宽度
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component;
//返回指定列的行的高度
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component;
// these methods return either a plain UIString, or a view (e.g UILabel) to display the row for the component.
// for the view versions, we cache any hidden and thus unused views and pass them back for reuse.
// If you return back a different object, the old one will be released. the view will be centered in the row rect
//标准的UIPickerView内容,只有字符串
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
//自定义的UIPickerView内容,给每列每行设置一个UIView
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view;
这里为列component,行row返回一个UIView来显示在UIPickerView中。reusingView:(UIView *) view 是IOS内核传入的一个缓冲的UIView。在程序中可以不用吧分配UIView,就可以重用IOS传来的view
//以上方法只能二选一
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;
@end
UIPickerView 用法相关推荐
- UIPickerView用法(左右比例,整体大小,字体大小)
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectZero]; pickerView.autoresizingM ...
- Swift - 选择框(UIPickerView)的用法
1,选择框可以让用户以滑动的方式选择值.示例如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ...
- RxSwift之UI控件UIPickerView扩展的使用
一.基本用法 ① 单列的情况 基本用法 示例代码: var pickerView : UIPickerView!// 最简单的pickerView适配器(显示普通文本) private let str ...
- 这个我过滤概述UIPickerView键盘处理
一.介绍UIPickView和UIDatePicker(了解) 1.UIPickView什么时候用? 通常在注册模块,当用户需要选择一些东西的时候,比如说城市,往往弹出一个PickerView给他们选 ...
- 【iOS开发】-UIPickerView
写在开头 昨天学习了iOS一个简单的控件. UIPickerView; UIPickerView组件类似HTML都Select组件效果,提供数据供用户选择.可以通过plist文件提供数据.UIPick ...
- OCUI界面设计:UIPickerView 拾取视图
简介 UIPickerView 是一个选择器控件, 它可以生成单列的选择器,也可生成多列的选择器,而且开发者完全可以自定义选择项的外观,因此用法非常灵活. UIPickerView 直接继承了 UIV ...
- c语言中external,static关键字用法
static用法: 在C中,static主要定义全局静态变量.定义局部静态变量.定义静态函数. 1.定义全局静态变量:在全局变量前面加上关键字static,该全局变量变成了全局静态变量.全局静态变量有 ...
- Pandas_transform的用法
先来看一个实例问题. 如下销售数据中展现了三笔订单,每笔订单买了多种商品,求每种商品销售额占该笔订单总金额的比例.例如第一条数据的最终结果为:235.83 / (235.83+232.32+107.9 ...
- Python中yield和yield from的用法
yield 后面接的是 future 对象 调用方 委托生成器 yield from 直接给出循环后的结果 yield from 委托者和子生成器直接通信 yield from 直接处理stopIte ...
最新文章
- 举个例子,如何用GCN图卷积神经网络实现摔倒监测?
- Python_time模块
- 女性养生需知的16条健康戒律
- DELL服务器利用OMSA修改BIOS设置
- FastStone Capture
- 在2019年,如何成为更好的Node.js开发者?
- merge sort loser tree
- Uncaught TypeError: Cannot read property ‘getters‘ of undefined
- 数据结构:下列选项中,不可能是快速排序第2趟排序结果的是(2019年全国试题10)
- python atm银行取款系统_Python实现ATM系统
- 《软件需求分析(第二版)》第 3 章——需求工程的推荐方法 重点部分总结
- 通过这本拼图学习Bash
- 通过SQL语句来备份,还原数据库
- 穿衣助手 张凯:电商产品经理的成长之路
- android 底层键值映射,如何在使用android-ETE时进行键值映射.doc
- ROS URDF模型解析成KDL Tree
- 假设检验 python_假的解释|假的意思|汉典“假”字的基本解释
- 读懂千行百业,萤石物联云平台全新能力发布
- 负数在计算机中的编码形式
- 从苏宁电器到卡巴斯基第24篇:单证这一年(下)