首页 > 代码库 > UIDatePicker控件

UIDatePicker控件

用处:选择日期或时间  当选择新的日期或时间的时候,值改变事件会被触发

-(void)viewDidLoad

{

    CGRect frame = CGRectMake(20,20,320,100);

  self.datePicker = [[UIDatePicker alloc]initWithFrame:frame];

  //设置显示模式

  self.datePicker.datePickerMode = UIDatePickerModeDate;

  [self.view addSubView:self.datePicker];

  CGRect framelbl = CGRectMake(0,300,320,50);

  self.label = [[UILable alloc]initWithFrame:framelbl];

  [self.view addSubView:self.label];

  //添加值改变事件

  [self.datePicker addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];

}