I want to create a view that consists solely of a UITextView
. When the view is first shown, by default, I\'d like the keyboard to be visible and ready for text
To automatically show the keyboard, to the following:
override func viewDidLoad() {
super.viewDidLoad()
// show keyboard
textView.becomeFirstResponder()
}
Notes
UITextView
and UITextField
textView.resignFirstResponder()
Following worked fine for me using Swift
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
// Show keyboard by default
billField.becomeFirstResponder()
}
Key is to use the viewDidAppear function.
to accomplish that just send the becomeFirstResponder message to your UITextField, as follows (assuming you have an outlet called textField, pointing to the field in question):
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[textField becomeFirstResponder];
}