// 初始化UIDatePicker
UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 200, 320, 216)];
// 设置时区
[datePicker setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
// 设置当前显示时间
[datePicker setDate:tempDate animated:YES];
// 设置显示最大时间(此处为当前时间)
[datePicker setMaximumDate:[NSDate date]];
// 设置UIDatePicker的显示模式
[datePicker setDatePickerMode:UIDatePickerModeDate];
// 当值发生改变的时候调用的方法
[datePicker addTarget:self action:@selector(datePickerValueChanged:)forControlEvents:UIControlEventValueChanged];
[self.view addSubview:datePicker];
// 获得当前UIPickerDate所在的时间
NSDate *currentDate = [datePicker date];