0

在我的iOS應用程序中,我有一個tabBarController與幾個navigationControllers。在applicationDidFinishLaunching tabBarController.selectedViewControllernull。這是我將navigationControllers分配給tabBar的tabBarItems後。tabBarController.selectedViewController的默認值?

什麼是tabBarController.selectedViewController的適當默認值?

也許它可以設置爲第一個navigationController。可能需要小心從後臺啓動應用程序(在這種情況下用戶可能沒有在第一個navigationController中停止)。

回答

4

UITabBarController文檔,下selectedViewController

此視圖控制器是其自定義視圖目前 由選項卡欄界面中顯示的一個。指定的視圖控制器必須 位於viewControllers數組中。將一個新的視圖控制器分配給 此屬性更改當前顯示的視圖,並在選項卡欄中選擇適當的選項卡 。也更改視圖控制器 相應地更新selectedIndex屬性。 默認值爲 此屬性爲零。