我正在尝试在文本字段中的 datePicker 中显示时间。我已经走到这一步了
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(112, 88, 97, 30)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
textField.text=[NSString stringWithFormat:@"%@",[NSDate //what do I put here to put the datepicker time in the textfield]];
[self.view addSubview:textField];
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeDate;
[datePicker addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged];
datePicker.timeZone = [NSTimeZone defaultTimeZone];
datePicker.minuteInterval = 5;
datePicker.datePickerMode = UIDatePickerModeTime;
[textField setInputView:datePicker];
编辑
我的值没有任何变化,但在这里
-(void)datePickerValueChanged:(id)sender{
}