iPhone datepicker instead of keyboard?

后端 未结 5 764
星月不相逢
星月不相逢 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:27

    I've converted Johan Kool's answer into swift if anyone would like it. I placed the code in viewDidLoad.

    let datePicker = UIDatePicker()
    datePicker.datePickerMode = UIDatePickerMode.Date
    datePicker.addTarget(self, action: "datePickerValueChanged:", forControlEvents: UIControlEvents.ValueChanged)
    textField.inputView = datePicker
    

提交回复
热议问题