The textFieldShouldReturn
function is not being called at all: there are no errors but the keyboard does not respond at all.
My case is different from How to hide keyboard in swift on pressing return key? as in my case nothing is happening at all and other cases are in Objective-C.
Here is my code:
import UIKit
class ViewController: UIViewController {
@IBOutlet var textField: UITextField!
func textFieldShouldReturn(textField: UITextField) -> Bool {
resignFirstResponder()
return true
}
}
textField is an outlet to a text field on my storyboard. I also tried self.endEditing
instead of resignFirstResponder
.