iPhone datepicker instead of keyboard?

后端 未结 5 780
星月不相逢
星月不相逢 2020-12-07 17:43

How would you do that?

I have a form with a UITextField. When I click in it I would like to display a UIDatePicker instead of the default Keyboard that pops-up by de

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 18:21

    I think this is a more official way to do this:

    UIDatePicker *datePicker = [[[UIDatePicker alloc] init] autorelease];
    datePicker.datePickerMode = UIDatePickerModeDate;
    [datePicker addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged];
    datePicker.tag = indexPath.row;
    textField.inputView = datePicker;
    

提交回复
热议问题