我有一个带有navigationController和storyboard的项目。 现在我需要添加另一个项目(结合两个项目) 我想使用TabbarController在两个navigationControllers之间切换。 我怎么能意识到这一点?
答案 0 :(得分:1)
在AppDelegates视图控制器中放下此代码: -
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UITabBarController *tabBar = [[UITabBarController alloc] init];
ViewController *homeVC = [[ViewController alloc] init];
homeVC.tabBarItem.title = @"Home";
homeVC.tabBarItem.image = [UIImage imageNamed:@"Home-icon.png"];
UINavigationController *HomeNavi = [[UINavigationController alloc] initWithRootViewController:homeVC];
settingViewController *settingVC = [[settingViewController alloc] init];
settingVC.tabBarItem.title = @"Setting";
settingVC.tabBarItem.image = [UIImage imageNamed:@"Setting-icon.png"];
UINavigationController *settingNavi = [[UINavigationController alloc] initWithRootViewController:settingVC];
tabBar.viewControllers = [NSArray arrayWithObjects:HomeNavi,settingNavi, nil];
HomeNavi.navigationBarHidden = YES;
settingNavi.navigationBarHidden = YES;
[self.window makeKeyAndVisible];
self.window.rootViewController = tabBar;
// Override point for customization after application launch.
return YES;
}