![](/img/trans.png)
[英]How to dismiss previous Viewcontroller after presenting new Viewcontroller using Swift?
[英]Keep keyboard opened after presenting new viewController
如果呈现新的viewController,如何保持键盘打开?
我有2个viewcontrollers: firstVC
, secondVC
。 firstVC
具有文本字段, secondVC
也具有文本secondVC
。 现在,如果我显示来自firstVC
secondVC
, firstVC
希望打开键盘,但是将其关闭。
根据文档,我尝试覆盖disablesAutomaticKeyboardDismissal
,由于某些原因,该disablesAutomaticKeyboardDismissal
:
override var disablesAutomaticKeyboardDismissal: Bool {
return true
}
我还应该做什么? 我不希望它被解雇然后分配becomeFirstResponder()
因为它会产生令人讨厌的动画。
我知道,如果要显示键盘(例如, 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.