I have this very weird problem that I just found out...
I have this button which is triggering this function:
@objc func vergessenTapped() {
let forgotPasswordVC = self.storyboard?.instantiateViewController(withIdentifier: "ForgotPasswordVC") as! ForgotPasswordVC
forgotPasswordVC.email = self.emailTextField.text!
self.present(forgotPasswordVC, animated: true, completion: nil)
}
I also have these function which hide/show the button above:
// delegate Methode für eye-Button
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
switch textField {
case passwordTextField:
if passwordTextField.text != "" {
eyeButton.isHidden = false
vergessenButton.isHidden = true
} else {
eyeButton.isHidden = true
}
break
default:
break
}
return true
}
// delegate Methode für eye-Button
func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
if textField == passwordTextField {
self.eyeButton.isHidden = true
self.vergessenButton.isHidden = false
}
return true
}
@objc func textFieldDidChange(_ textField: UITextField) {
if textField.text == "" {
self.eyeButton.isHidden = true
self.vergessenButton.isHidden = false
}else {
self.vergessenButton.isHidden = true
self.eyeButton.isHidden = false
}
}
Now the Problem:
When I press the button the first time before any of the delegate-function above are hiding it, the ViewController it presents works just fine.
However: As soon as the button is hidden for the first time, and the user clicks it after it is visible again the forgotpasswordViewController behaves really really weird, e.g:
1. when calling self.dismiss , the `ViewController is actually not dismissed, but is popping the one below it.
@objc func backButtonTapped(){
self.dismiss(animated: true, completion: nil)
}
2. The button in the forgotpasswordViewController (only one button there) is not doing anything.
Here is a Screenvideo for a better understanding. 22 seconds into the video I start typing (somehow not visible on the screenvideo but you can see that the "vergessen" but disappears and appears again. After appearing again I click it and as you can see, neither the backButton nor the confirmButton work like they did before...
Is this some kind of bug??? I can't explain it .. so if anyone helps me out here I would really appreciated!
Demo-Project: