iOS UIKit框架学习—UIPickerView

UIPickerView 类实现对象,称为选取器视图,用纺车或老虎机的隐喻来显示一个或多个集合的值。用户通过旋转的车轮,以便与选择指示器对齐所需的行的值来选择值

@protocol UIPickerViewDataSource, UIPickerViewDelegate;

NS_CLASS_AVAILABLE_IOS(2_0) __TVOS_PROHIBITED @interface UIPickerView : UIView 
// 数据源
@property(nullable,nonatomic,weak) id dataSource;
// 代理
@property(nullable,nonatomic,weak) id   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
@required

// 返回要显示列的数目
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
// 返回指定选择器的组件的行数
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
@end

__TVOS_PROHIBITED
@protocol UIPickerViewDelegate
@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

你可能感兴趣的:(iOS UIKit框架学习—UIPickerView)