In iOS 8+ I noticed that if you have an textfield that is currently the firstResponder
in a view controller that was presented, when the view controller is dism
According to this, in iOS 8 it seems the view doesn’t resign first responder status until it’s actually offscreen.
http://prod.lists.apple.com/archives/cocoa-dev/2014/Sep/msg00391.html
Our workaround is to call [self.view endEditing:YES]
in -viewWillDisappear
.
For Swift 3/4
override func viewWillDisappear(_ animated: Bool) {
self.view.endEditing(true)
}
Also if it's not resigning try calling resignFirstResponder
on the text field you're trying to end typing on.
override func viewWillDisappear(_ animated: Bool) {
textField.resignFirstResponder()
}