self.inputTextView.becomeFirstResponder()
To hide the keyboard:
self.inputTextView.resignFirstResponder()
To hide the keyboard while tapping outside the UITextField/UITextField:
@IBOutlet weak var inputTextView: UITextView!
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
self.inputTextView.resignFirstResponder()
}
To hide the keyboard while tapping the return key in the UITextField:
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var inputTextField: UITextField!
func textFieldShouldReturn(textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
override func viewDidLoad() {
super.viewDidLoad()
self.inputTextField.delegate = self
Thank you VERY MUCH!!! :)
ReplyDelete