I am using UITextField\'s method becomeFirstResponder to show the keyboard. This is working in iOS 7. But in iOS 8 this method doesn\'t show the keyboard.
U
For iOS 9.3, the following worked for me:
private var searchTextFieldShouldReturn = false
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.searchTextFieldShouldReturn = false
self.searchTextField.becomeFirstResponder()
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
self.searchTextFieldShouldReturn = true
self.searchTextField.resignFirstResponder()
}
func textFieldShouldReturn(textField: UITextField) -> Bool {
self.searchTextFieldShouldReturn = true
textField.resignFirstResponder()
return true
}
func textFieldShouldEndEditing(textField: UITextField) -> Bool {
return self.searchTextFieldShouldReturn
}
So You need to make sure You also implement the textFieldShouldEndEditing delegate.