IOS7 viewDidLoad中调用 pushViewController 的问题

 

   相信也有个别朋友遇到与我相同的状况,状况是这样:A视图->B视图->C视图。跳转的实现都是采用pushViewController而且附带动画,其中跳转到C视图的push跳转代码在B视图的动画

viewDidLoad方法中执行:google

Class B:spa

-(void)viewDidLoad{code

  [super viewDidLoad];    内存

  [self.navigationController pushViewController:CView animated:YES];文档

}get

除非运行在IOS7中,这段代码运行是能正常的,在IOS7中运行的结果是这样的,A视图跳转到B视图后,就定在B视图了,没法跳转到C视图,而且是保证[self.navigationController pushViewController:CView animated:YES];已经执行的状况下。同时控制台会打印信息:animation

Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.it

按照字面意识视乎是,导航栏转换出现异常,可是没法让人理解缘由,查阅了一些官方的文档,关于viewDidLoad的:io

This method is called after the view controller has loaded its view hierarchy into memory。

意思是  view controller将该视图按层次被加载进内存后执行。对解决这个问题并无什么帮助。

我在网上google了下,有个别解释比较典型,现分享下:

The problem is that you are pushing a new view to the UINavigationController while the first animation is still in place. If you move the Segue invocation to ViewDidAppear you would solve the crash.

意思是:在viewDidLoad中push新视图(动画 yes)的时候,首要动画正在进行而没法进行视图切换动画。这个说法我比较赞同,由于在把动画参数设置为NO的时候,是能够达到效果的,只是没动画效果感受不优雅。但也没法解释IOS7之外版本为何能够正常运行。若是有人知道请留言,谢谢。

相关文章
相关标签/搜索