iOS 8 Swift : How to keep the keyboard displayed when the UIAlercontroller is presented modally?

南笙酒味 提交于 2019-12-24 04:20:22

问题


The context is pretty simple, there is a UIViewcontroller with a textfield to enter a phone number. The textfield is in editing mode with keyboard.

When the number is entered, the user can tap a button which displays an alert controller. As the alert is presented modally it covers the UIViewcontroller and removes keyboard, the editing is no more enabled.

Thus my question, what should be done to keep the keyboard displayed behind the alert?


回答1:


This solution worked

let rootViewController: UIViewController = UIApplication.sharedApplication().windows[1].rootViewController!!
rootViewController.presentViewController(alert, animated: true, completion: nil)



回答2:


I believe you can't. Better try making custom alert which can allow pass-through gestures.



来源:https://stackoverflow.com/questions/28559162/ios-8-swift-how-to-keep-the-keyboard-displayed-when-the-uialercontroller-is-pr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!