问题
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