我使用2 ViewControllers
創建基本TabBarController
。 它的工作,但它有錯誤,我想要一些東西。如何更改UITabBarController的默認ViewController
問題1。
當我運行在TabBar
的SecondViewController
(默認ViewController is FirstViewController
)的名字沒有出現。
我想下面的這張圖片。
Problem2。 在我的代碼中,默認視圖是FirstViewController
。 如果我想設置默認視圖是SecondViewController
Same Tab Bar(FirstView
Tab:Left,and SecondView
Tab:Right) 下面這張圖片。如何解決它。
這是我的示例代碼
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
FirstViewController *firstVC = [[FirstViewController alloc] init];
UINavigationController *firstNVC = [[UINavigationController alloc] initWithRootViewController:firstVC];
firstNVC.navigationBar.barStyle = UIBarStyleBlack;
SecondViewController *secondVC = [[SecondViewController alloc] init];
UINavigationController *secondNVC = [[UINavigationController alloc] initWithRootViewController:secondVC];
secondNVC.navigationBar.barStyle = UIBarStyleBlack;
UITabBarController *tabController = [[UITabBarController alloc]init];
tabController.navigationItem.hidesBackButton = NO;
tabController.viewControllers = [NSArray arrayWithObjects:firstNVC, secondNVC, nil];
tabController.navigationController.navigationBarHidden = NO;
self.window.rootViewController = tabController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
謝謝。 ^^
非常感謝你。 我使用[[[[[self.tabBarController tabBar] items] objectAtIndex:0] setTitle:@「1」]; ^^ –