iOS - Dismiss UIDatePicker presented as inputView

前端 未结 4 928

I have a text field in my UI that when it\'s selected presents a UIDatePicker instead of the default keyboard, how could I set up a button as to dismiss the picker when the

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-18 05:18

    What I do is have my inputView as a custom view which contains a UIDatePicker and a toolbar above it with a 'Done' button wired up to a method that calls a delegate method to tell the object that owns the UITextField to dismiss the "keyboard" by calling resignFirstResponder.

提交回复
热议问题