UIAlertController is moved to buggy position at top of screen when it calls `presentViewController:`

I encountered a situation where sometimes a modal view would present itself on top of a an alert (silly situation, I know), and the UIAlertController could appear in the top left (like the 2nd screenshot of the original question), and I found a one-liner solution that seems to work. For the controller that’s about to be presented on the UIAlertController, change its modal presentation style like so:

viewControllerToBePresented.modalPresentationStyle = .OverFullScreen

This should be done just before you call presentViewController(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion completion: (() -> Void)?)

Leave a Comment