How to keep the keyboard opened if presenting new viewController?
I have 2 viewcontrollers: firstVC
, secondVC
. firstVC
has textfield and secondVC
has it also. Now if I present secondVC
from firstVC
I want the keyboard to be opened but it dismisses it.
According to documentation I tried overriding the disablesAutomaticKeyboardDismissal
which is not working for some reason:
override var disablesAutomaticKeyboardDismissal: Bool {
return true
}
What else I should do? I do not want that it dismisses then assign becomeFirstResponder()
because it makes nasty animation.
I know that if you want to keep keyboard opened if you present for example an UIAlertView
then you can do this:
let rootViewController: UIViewController = (UIApplication.shared.windows.last?.rootViewController)!
rootViewController.presentViewController(alert, animated: true, completion: nil)
txtcode.becomeFirstResponder()
在txtcode中替换您的文本字段名称,并为相同的名称提供委托
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.