简体   繁体   English

呈现新的viewController后保持键盘打开

[英]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: firstVCsecondVC 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 secondVCfirstVC希望打开键盘,但是将其关闭。

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.

相关问题 在使用Swift展示新的Viewcontroller后如何关闭以前的Viewcontroller? - How to dismiss previous Viewcontroller after presenting new Viewcontroller using Swift? Swift 在呈现新的 ViewController 后关闭当前的 ViewController - Swift dismiss current Viewcontroller after presenting new ViewController 呈现后模糊Viewcontroller变暗 - Blur viewcontroller darkens after presenting 呈现一个新的时销毁先前的viewController - Destroy previous viewController when presenting a new one 呈现新的viewController时显示progressHUD - Showing progressHUD when presenting a new viewController 仅在呈现viewcontroller之后才应调用shouldAutorotateToInterfaceOrientation - shouldAutorotateToInterfaceOrientation is only called after presenting viewcontroller 有没有办法在呈现另一个ViewController之后将其关闭? - Is there a way to dismiss the current ViewController after presenting another? presentModalViewController - ViewController在呈现后自动消失 - presentModalViewController - ViewController automatically disappears after presenting 消除解雇ViewController和展示新ViewController之间的延迟 - Remove delay between dismissing viewcontroller and presenting new viewcontroller 呈现viewController之后,呈现viewController会发生什么? - What happens with presenting viewController after it presents a presented viewController?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM