iOS 開發過程中常出現的一些錯誤總結

來源:互聯網
上載者:User

標籤: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 開發過程中常出現的一些錯誤總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.