![]()
1 一.UIPickerView
2 1.UIPickerView的常见属性
3 // 数据源(用来告诉UIPickerView有多少列多少行)
4 @property(nonatomic,assign) id<UIPickerViewDataSource> dataSource;
5 // 代理(用来告诉UIPickerView每1列的每1行显示什么内容,监听UIPickerView的选择)
6 @property(nonatomic,assign) id<UIPickerViewDelegate> delegate;
7 // 是否要显示选中的指示器
8 @property(nonatomic) BOOL showsSelectionIndicator;
9 // 一共有多少列
10 @property(nonatomic,readonly) NSInteger numberOfComponents;
11
12 2.UIPickerView的常见方法
13 // 重新刷新所有列
14 - (void)reloadAllComponents;
15 // 重新刷新第component列
16 - (void)reloadComponent:(NSInteger)component;
17
18 // 主动选中第component列的第row行
19 - (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated;
20
21 // 获得第component列的当前选中的行号
22 - (NSInteger)selectedRowInComponent:(NSInteger)component;
23
24 3.数据源方法(UIPickerViewDataSource)
25 // 一共有多少列
26 - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
27 // 第component列一共有多少行
28 - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
29
30 4.代理方法(UIPickerViewDelegate)
31 // 第component列的宽度是多少
32 - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component;
33 // 第component列的行高是多少
34 - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component;
35
36 // 第component列第row行显示什么文字
37 - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
38
39 // 第component列第row行显示怎样的view(内容)
40 - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view;
41
42 // 选中了pickerView的第component列第row行
43 - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;
44
45 二.UIDatePicker
46 1.常见属性
47 // datePicker的显示模式
48 @property (nonatomic) UIDatePickerMode datePickerMode;
49 // 显示的区域语言
50 @property (nonatomic, retain) NSLocale *locale;
51
52 2.监听UIDatePicker的选择
53 * 因为UIDatePicker继承自UIControl,所以通过addTarget:...监听
54
55 三.程序启动的完整过程
56 1.main函数
57
58 2.UIApplicationMain
59 * 创建UIApplication对象
60 * 创建UIApplication的delegate对象
61
62 3.delegate对象开始处理(监听)系统事件(没有storyboard)
63 * 程序启动完毕的时候, 就会调用代理的application:didFinishLaunchingWithOptions:方法
64 * 在application:didFinishLaunchingWithOptions:中创建UIWindow
65 * 创建和设置UIWindow的rootViewController
66 * 显示窗口
67
68 3.根据Info.plist获得最主要storyboard的文件名,加载最主要的storyboard(有storyboard)
69 * 创建UIWindow
70 * 创建和设置UIWindow的rootViewController
71 * 显示窗口