相信也有個別朋友遇到與我相同的狀況,狀況是這樣: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之外版本爲何能夠正常運行。若是有人知道請留言,謝謝。