Closed dreed47 closed 6 years ago
Hey @dreed47, thanks for letting us know about that!
I had this problem in the past when I was using other libraries like IQKeyboardManger, but your problem seems like you're not using any. Can you share an example project so I can help you fix that?
sure, you can look at this simple example
https://github.com/dreed47/datedialogtest
thanks for your help!
Thanks for taking time to make an example project. After about an hour, I remembered how I fixed that. Instead of using an @IBAction
for the dateTapped()
, use textFieldShouldBeginEditing()
.
import UIKit
import DatePickerDialog
class ViewController: UIViewController {
@IBOutlet var firstTextField: UITextField!
@IBOutlet var dateTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
firstTextField.becomeFirstResponder()
firstTextField.delegate = self
dateTextField.delegate = self
}
func dateTapped() {
DatePickerDialog().show("DatePicker", doneButtonTitle: "Done", cancelButtonTitle: "Cancel", datePickerMode: .date) {
(date) -> Void in
self.dateTextField.text = "\(String(describing: date))"
}
}
}
extension ViewController: UITextFieldDelegate {
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
if textField == dateTextField {
dateTapped()
return false
}
return true
}
}
Closing this, but feel free to reopen if you have any questions
this worked for me. thanks! might want to update the installation docs so others use the correct approach. thanks
@dreed47 that method on the docs is a button @IBAction and not a textfield, but I'll update it anyways for clarity
I have a simple view that has 2 text fields. The first text field takes normal input via the keyboard, the second textfield is my date field. When I when I tap on the date field when the keyboard is already showing the date picker dialogbox shows but the keyboard is not dismissed. I've tried to dismiss the keyboard via "view.endEditing(true)" and also firstTextField.resignFirstResponder() but nothing works. On some devices the keyboard covers the date picker dialogbox which leaves the user in a state where they have to force quit the app.