标签:
当我想从一个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!
标签:
原文地址:http://www.cnblogs.com/Mr-Lin/p/5172106.html