![](/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.