1. 程式人生 > >iOS 導航欄錯誤 nested push animation can result in corrupted navigation bar

iOS 導航欄錯誤 nested push animation can result in corrupted navigation bar

nested pop animation can result in corrupted navigation bar

nested pop animation can result in corrupted navigation bar

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


【情況一】
出現此問題的原因是在A介面彈出B介面完成後,又掉A介面POP出棧,這必然導致以上問題。如下,在彈出personalController後面,又在後面呼叫了

[self.navigationController popViewControllerAnimated:YES];將自己彈出!解決方法,還用說嗎?{刪除最後一行程式碼,要彈出此介面,自然有自己的返回按鈕來處理},至少在B介面未POP以前,A介面是無論如何也不能將自己POP去消毀!

NSString*memberId = [dictionary objectForKey:@"PlayerNo"];

PersonalInfoViewController*personalController = [[PersonalInfoViewController alloc] init];

[personalController.navigationItems etHidesBackButton:YES];

[personalController setMemberId:memberId];

[self.navigationController pushViewController:personalController animated:YES];

[personalController release];

[self.navigationController popViewControllerAnimated:YES];


【情況二】

nested push animation can result in corrupted navigation bar 巢狀的navigation動畫會造成  navigation bar  錯誤, 具體表現為上一層的titleview 和這一層重疊, navigationbaritem  維持上一層的左按鈕, 右按鈕 、、、系統警告提示nested push animation can result in corrupted navigation bar

從頭到尾分析了整個專案的程式碼, 最後確認問題根源——自定義UITabbarController引發的血案

專案中使用了自定義的UITabbarController ,修改裡面的tabbar檢視, 在這個UITabbarController 中實現了viewWillAppear方法, 裡面沒有加super viewWillAppear , 結果導致了這一連串的問題,

     整個軟體裡面,都會出現彈一次模態視窗,導航檢視就會動畫亂序,

    導航檢視前進後退過快, 導致導航欄巢狀, 一個上面覆蓋另一個。

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}