我已经以编程方式创建了tabbar控制器。下面是我的Tab栏控制器代码。
RecordedAudioListViewController *recordedAudioListViewController = [[RecordedAudioListViewController alloc] initWithNibName:@"RecordedAudioListViewController" bundle:nil];
recordedAudioListViewController.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"Recording" image:spongebob tag:0];
UINavigationController *firstNavController = [[UINavigationController alloc]initWithRootViewController:recordedAudioListViewController];
firstNavController.navigationBarHidden = YES;
RecordViewController *recordViewController = [[RecordViewController alloc]initWithNibName:@"RecordViewController" bundle:nil];
recordViewController.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"Record" image:patrick tag:1];
UINavigationController *secondNavController = [[UINavigationController alloc]initWithRootViewController:recordViewController];
secondNavController.navigationBarHidden = YES;
SettingViewController *settingViewController = [[SettingViewController alloc]initWithNibName:@"SettingViewController" bundle:nil];
settingViewController.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"Setting" image:spongebob tag:2];
UINavigationController *thirdNavController = [[UINavigationController alloc]initWithRootViewController:settingViewController];
thirdNavController.navigationBarHidden = YES;
tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
tabBarController.viewControllers = [[NSArray alloc] initWithObjects:firstNavController, secondNavController, thirdNavController, nil];
tabBarController.delegate = self;
tabBarController.selectedIndex = 1;
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
在下图中,您可以看到视图控制器从屏幕顶部移出。