Present modal view controller over modal view controller

You can only present on a visible controller, which is usually the rootViewController. But when there is a modally-presented controller, it covers the root controller, so you can't use that. But you can present on the modal, which is accessed though rootViewController.prsentedViewController. Here's some code:

let rootVC = window?.rootViewController
let presentingVC = (rootVC?.presentedViewController ?? rootVC)
presentingVC?.present(myController, animated: true, completion: nil)

You don't need to change the modalPresentationStyle.


let newView = self.storyboard!.instantiateViewControllerWithIdentifier("NewViewController") as! NewViewController

newView.modalPresentationStyle = UIModalPresentationStyle.OverFullScreen

self.presentViewController(newView, animated: true, completion: nil)