UIViewController *newView = [[UIViewController alloc] initWithNibName:@"NewView" bundle:[NSBundle mainBundle]];
tabBarController.selectedViewController = newView;
爲什麼不能正常工作?在uitabbar應用程序中更改當前視圖iOS iPad
UIViewController *newView = [[UIViewController alloc] initWithNibName:@"NewView" bundle:[NSBundle mainBundle]];
tabBarController.selectedViewController = newView;
爲什麼不能正常工作?在uitabbar應用程序中更改當前視圖iOS iPad
UITabBarController的selectedViewController屬性必須是選項卡欄的現有選項卡之一(如其viewControllers屬性中所定義)。您可能希望將新控制器推送到現有的選項卡上(這必須是UINavigationController),或者將viewController添加到viewControllers數組中。
因爲該視圖控制器不是UITabBarController
的一部分。
如果你看一下在selectedViewController
財產蘋果的參考,你會看到:
指定的視圖控制器必須是
viewControllers
陣列 。
您需要的視圖控制器添加到UITabBarController
,使用viewControllers
屬性,所以視圖控制器有一個標籤,這樣,那麼你可以選擇視圖控制器的標籤。
我使用IB編程了當前標籤欄,而不是編程式,int numControllers = [tabBarController.viewControllers count];返回0 - 我猜這與它有關 – DaveyDivDovs 2010-09-13 01:25:49