Arthur
Arthur

Reputation: 1760

How to add TabbarController to NavigationController

I have a project with navigationController and storyboard. Now i need to add another project to this (combine two projects) I want to use TabbarController to switch between two navigationControllers. How can I realise this?

Upvotes: 0

Views: 70

Answers (1)

user4226872
user4226872

Reputation:

put Down this Code in Your AppDelegates view controller :-

 @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;
}

Upvotes: 1

Related Questions