2

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?

3

2 Answers 2

2

This solution worked

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

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

2
  • Thanks Amresh for your answer. I might not have been precise enough. I just want the keyboard to be displayed and cursor in textfield (editing mode) behind alert. I'm not looking for any user interaction regarding textfield.
    – Sam
    Commented Feb 17, 2015 at 10:02
  • I have never tried this before, but may be returning NO from canResignFirstResponder for the current text field can do the trick
    – Amresh
    Commented Feb 17, 2015 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.