I have a UIDatePicker displayed with a WHEEL mode, but when I click on a date, the keyboard comes up, letting me enter a date from KEYPAD. How to disable this ridiculous behavior (why would anyone want that anyway???)
Apple's documentation on this is rather lacking -- I haven't been able to find any reference to that functionality.
However, it is clearly built-in as a convenient method for a user to enter the time with the Keypad.
You can prevent the Keypad from showing like this:
@IBOutlet var datePicker: UIDatePicker!
override func viewDidLoad() {
super.viewDidLoad()
datePicker.addTarget(self, action: #selector(noKeypad(_:)), for: .editingDidBegin)
}
@IBAction func noKeypad(_ sender: UIDatePicker) {
sender.resignFirstResponder()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With