標籤:iphone開發 ios 常見錯誤總結 跳轉 push
iOS 開發過程中常出現的一些錯誤總結
1、兩個視圖控制器之間的跳轉
(1)跳轉:[self presentModalViewController:control animated:YES];
返回:[self dismissModalViewControllerAnimated:YES];
(2)
跳轉:[self.navigationController pushViewController:subTableViewController animated:YES];
返回:[self.navigationController popViewControllerAnimated:YES];
2、【ios報錯】reason: ‘Pushing anavigation controller is not supporter
reason: ‘Pushing a navigation controller is not supported‘
報上面的錯誤,原因是:
大家知道,可以將ViewControllerpush到一個 NavigationController中。就像是入棧操作!
將一個NavigationController再次push到NavigationController中時,報錯,出現了
reason: ‘Pushing a navigation controller isnot supported‘
的錯誤。應該是,NavigationController不支援push進來的對象是NavigationController。將NavigationController改為viewController
3、ios 中UITableViewCell調用pushViewController:沒反應(即整頁模式控制器之間不能進行跳轉)
總結一下使用UINavigationController遇到的一些問題:
(1)、self.navigationController==nil
(2)、[self.navigationControllerpushViewController: xxxController animate:yes]後沒有back按鈕;
4、Warning:Attempt to present on whose view is not in the window hierarchy!
Warning: Attempt to present on whose view is not in thewindow hierarchy!
等等這樣類似的提示,只要裡面提示有 windowhierarchy,都是view hierarchy的理解不到位導致的。
上面的問題都是在一個controller的view還沒加到window上的時候又取present另外一個controller,這就相當於在蓋樓,2樓還沒蓋完,直接去蓋3樓了,這樣肯定是不行。
遇到上面的問題 最直接的解決方案就是在controller的viewDidAppear裡面去調用present。這樣可以確保view hierarchy的階層不亂。
http://blog.csdn.net/sbvfhp/article/details/19826221
5、Presentingview controllers on detached view controllers is discouraged。
把[self.rootViewControllerpresentViewController:controller animated:YES completion:nil];
改為[self.view.Window.rootViewControllerpresentViewController:controller animated:YES completion:nil];
iOS 開發過程中常出現的一些錯誤總結