In one of my apps, I'm calling a viewController from the application didReceiveLocalNotification
method. The page loads successfully, but it shows a warning as :
Warning: Attempt to present <blankPageViewController: 0x1fda5190> on
<ViewController: 0x1fd85330> whose view is not in the window hierarchy!
My code is as follows :
-(void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
blankPageViewController *myView = [[blankPageViewController alloc]
initWithNibName:@"blankPageViewController" bundle: nil];
myView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.viewController presentViewController:myView animated:NO completion:nil];
}
For
Swift 2.0
I used an override forviewDidAppear
with:let vc = self.storyboard?.instantiateViewControllerWithIdentifier("Second") as! SecondViewController
Where "Second" is storyboard ID of the SecondViewController in the identity inspector.
If your application type id UINavigationController then you can use.
Hope this will help you. All the best !!!
Put
into a function e.g.
and then call it like this:
The problem got described here and why does this
performSelector:withObject:afterDelay
fix this problem? Because the selector will not be called until the next run of the run loop. So things have time to settle down and you will just skip one run loop.