iOS中使用UIDatePicker制作时间选择器的实例教程

2020-01-15 14:40:24于海丽

UIDatePicker,iOS,时间选择器

单击按钮后,弹出一个Alert,用于显示用户所作选择。

4、创建映射:打开Assistant Editor,选中UIDatePicker控件,按住Control,拖到ViewController.h中:

UIDatePicker,iOS,时间选择器

新建一个Outlet,名称为datePicker:

UIDatePicker,iOS,时间选择器

然后以同样的方式为按钮建立一个Action映射,名称为buttonPressed,事件类型为默认的Touch Up Inside。

5、选中UIDatePicker控件,打开Attribute Inspector,在其中设置Maximum Date比如我们这里设为2100-12-31:

UIDatePicker,iOS,时间选择器