[英]Keep keyboard opened after presenting new viewController
How to keep the keyboard opened if presenting new viewController? 如果呈现新的viewController,如何保持键盘打开?
I have 2 viewcontrollers: firstVC
, secondVC
. 我有2个viewcontrollers: firstVC
, secondVC
。 firstVC
has textfield and secondVC
has it also. firstVC
具有文本字段, secondVC
也具有文本secondVC
。 Now if I present secondVC
from firstVC
I want the keyboard to be opened but it dismisses it. 现在,如果我显示来自firstVC
secondVC
, firstVC
希望打开键盘,但是将其关闭。
According to documentation I tried overriding the disablesAutomaticKeyboardDismissal
which is not working for some reason: 根据文档,我尝试覆盖disablesAutomaticKeyboardDismissal
,由于某些原因,该disablesAutomaticKeyboardDismissal
:
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. 我不希望它被解雇然后分配becomeFirstResponder()
因为它会产生令人讨厌的动画。
I know that if you want to keep keyboard opened if you present for example an UIAlertView
then you can do this: 我知道,如果要显示键盘(例如, UIAlertView
保持键盘打开,则可以执行以下操作:
let rootViewController: UIViewController = (UIApplication.shared.windows.last?.rootViewController)!
rootViewController.presentViewController(alert, animated: true, completion: nil)
txtcode.becomeFirstResponder()
在txtcode中替换您的文本字段名称,并为相同的名称提供委托
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.