I am trying to present a view programmatically from the appdelegate. The basic idea it's to present a view so that the user must enter a code to unlock the app. This code works
func applicationWillResignActive(application: UIApplication) {
var storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var vc : PasswordViewController = storyboard.instantiateViewControllerWithIdentifier("PasswordViewController") as PasswordViewController
let navigationController = UINavigationController(rootViewController: vc)
self.window?.rootViewController?.presentViewController(navigationController, animated: true, completion: nil)
}
But have a problem. If the user press home inside another view (like the one shown on the picture) the password viewcontroller does not shows and I get a warning
Warning: Attempt to present UINavigationController: 0x7f8c2263c480 on UITabBarController: 0x7f8c2256ad60 whose view is not in the window hierarchy!
left view presents ok the view, right one not, note that right one is accessed with the + button and it's modal
Any help will be much welcome!