我有基於TabBar的iPhone應用程序,並且在應用程序委託2中,默認視圖控制器由蘋果初始化(如果您在創建應用程序時選擇了tabbar基本應用程序)。初始化自定義UIViewController
UIViewController *rootViewController = [[tabBarBetFirstViewController alloc] initWithNibName:@"tabBarBetFirstViewController" bundle:nil];
UIViewController *accountViewController = [[tabBarBetSecondViewController alloc] initWithNibName:@"tabBarBetSecondViewController" bundle:nil];
爲什麼這不是初始化這樣的:
tabBarBetFirstViewController *rootViewController = [[tabBarBetFirstViewController alloc] initWithNibName:@"tabBarBetFirstViewController" bundle:nil];
tabBarBetSecondViewController *accountViewController = [[tabBarBetSecondViewController alloc] initWithNibName:@"tabBarBetSecondViewController" bundle:nil];
???
這是一樣的嗎?或者這只是由蘋果添加的那些默認設置?如果我想補充一個選項卡將我寫的:
UIViewController *third = [ThirdViewController alloc].....];
或
ThirdViewController *third = [ThirdViewController alloc]....];
當然在最後我有:
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:rootViewController, accountViewController, third, nil];
只是要注意,我用的是蘋果的版本,UIViewController中*第三= [ThirdViewController頁頭] ...];和它的工作......但只是想知道什麼是正確的做法。 – user1832330