[ACCEPTED]-How to open the keyboard automatically on UITextField?-builder
Accepted answer
To cause the keyboard to show up immediately 3 you'll need to set the text field as the 2 first responder using the following line:
[textField becomeFirstResponder];
You 1 may want to place this in the viewDidAppear:
method.
Swift 3 & 4:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
textField.becomeFirstResponder()
}
0
override func viewDidLoad() {
super.viewDidLoad()
textField.becomeFirstResponder()
}
0
Prefer adding the first responder on the 2 main thread -
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
DispatchQueue.main.async {
self.textField.becomeFirstResponder()
}
}
This will come in handy when 1 view controller view is added as a subview.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.