UITabBarController使用須知

UITabBarController在我們的開發中經常被用到。關於它的使用,有幾個須要注意的地方:
1、UITabBarController會抗拒和別的視圖控制器組合,所以最好只將UITabBarController做爲整個App的根視圖。

 When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.  [Apple]
蘋果的官方文檔裏要求我們將UITabBarController實例做爲整個應用的“根”,這是最爲被蘋果接受的用法。
參考:http://blog.zhaojie.me/2010/12/iphone-composition-resistant-uitabbarcontroller.html

        http://stackoverflow.com/questions/8929462/uinavigationcontroller-pushing-uitabbarcontroller-only-displays-one-tab

2、最好不要去子類化UITabBarController。
This class is not intended for subclassing. Instead, you use instances of it as-is to present an interface that allows the user to choose between different modes of operation. [Apple]
蘋果建議我們最好不要去子類化它,這個類主要被設計用來管理多個view controller並且展示多個view。

3、UITabBarController的viewControllers數組中不要出現相同的指針,標籤欄控制器不會爲相同的指針創建有效的標籤。
Because selecting a tab replaces the contents of the interface, the type of interface managed in each tab need not be similar in any way. [Apple]







發佈了28 篇原創文章 · 獲贊 0 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章