警告:尝试呈现其视图不在窗口层次结构中的ViewController [英] Warning: attempt to present ViewController whose view is not in the window hierarchy
本文介绍了警告:尝试呈现其视图不在窗口层次结构中的ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的一个应用程序中,我从应用程序didReceiveLocalNotification
方法调用viewController。页面加载成功,但它显示警告:
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!
我的代码如下:
-(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];
}
推荐答案
最后我解决了这个问题以下代码。
Finally I solved that issue with the following code.
-(void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.blankviewController = [[blankPageViewController alloc] initWithNibName:@"blankPageViewController" bundle:nil];
self.window.rootViewController = self.blankviewController;
[self.window makeKeyAndVisible];
}
这篇关于警告:尝试呈现其视图不在窗口层次结构中的ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文