iOS UIKit框架学习—UIPickerView 发表于 2017-01-25 | 分类于 iOS | | 阅读次数: UIPickerView 类实现对象,称为选取器视图,用纺车或老虎机的隐喻来显示一个或多个集合的值。用户通过旋转的车轮,以便与选择指示器对齐所需的行的值来选择值 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657@protocol UIPickerViewDataSource, UIPickerViewDelegate;NS_CLASS_AVAILABLE_IOS(2_0) __TVOS_PROHIBITED @interface UIPickerView : UIView <NSCoding>// 数据源@property(nullable,nonatomic,weak) id<UIPickerViewDataSource> dataSource;// 代理@property(nullable,nonatomic,weak) id<UIPickerViewDelegate> delegate;// 是否显示选择指示符@property(nonatomic) BOOL showsSelectionIndicator; // default is NO// 获取该选择视图组件的数量@property(nonatomic,readonly) NSInteger numberOfComponents;// 返回组件的行数- (NSInteger)numberOfRowsInComponent:(NSInteger)component;// 返回组件行的大小- (CGSize)rowSizeForComponent:(NSInteger)component;// 返回指定行和控件的视图控制器- (nullable UIView *)viewForRow:(NSInteger)row forComponent:(NSInteger)component;// 刷新单一视图组件或全部- (void)reloadAllComponents;- (void)reloadComponent:(NSInteger)component;// 将指定的行滚动到选择器中心- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated;// 返回选定的组件的下标- (NSInteger)selectedRowInComponent:(NSInteger)component;@end__TVOS_PROHIBITED@protocol UIPickerViewDataSource<NSObject>@required// 返回要显示列的数目- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;// 返回指定选择器的组件的行数- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;@end__TVOS_PROHIBITED@protocol UIPickerViewDelegate<NSObject>@optional// 返回组件列的宽度和高度- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component __TVOS_PROHIBITED;- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component __TVOS_PROHIBITED;// 给组件设置标题- (nullable NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component __TVOS_PROHIBITED;// 给组件设置带样式的标题- (nullable NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;// 设置指定的行指定组件的视图- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(nullable UIView *)view __TVOS_PROHIBITED;// 用户选择组件中的行时调用- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component __TVOS_PROHIBITED;@end