你的位置:首页 > 软件开发 > 操作系统 > Warning: Attempt to present on whose view is not in the window hierarchy!

Warning: Attempt to present on whose view is not in the window hierarchy!

发布时间:2016-01-30 22:00:06
当我想从一个VC跳转到另一个VC的时候,一般会用- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ ...

当我想从一个VC跳转到另一个VC的时候,一般会用

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion;当然也可以用导航push。

有时会遇到了此类警告:Warning: Attempt to present on whose view is not in the window hierarchy!

原因:页面跳转必须在viewDidLoad和viewDidAppear之后才能进行。

解决办法:必须确保页面跳转要在view load完毕之后进行。

第一种:通过延时来等待view Load执行结束,但是这个方法在时间上不好把握

第二种:在viewDidLoad里用

 [selfperformSelectorOnMainThread:@selector(login)withObject:nilwaitUntilDone:NO];

把页面跳转的代码写进函数里,然后将 waitUntilDone 设为NO


原标题:Warning: Attempt to present on whose view is not in the window hierarchy!

关键词:ie

ie
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。