Arthur
Arthur

Reputation: 1760

How to start app from specific TabbarController

I have a NavigationController for registration, after that I'm switching on another NavigationController with main logic. Here is my code for switshing:

    NSString *containerName = @"MainContainer";
    UINavigationController *root = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:containerName];

    UIWindow *wnd = [[[UIApplication sharedApplication] delegate] window];
    wnd.rootViewController = root;
    [wnd makeKeyAndVisible];

But now I need to change NavigationController to TabbarController. How to switch on tabbar?

edit

Before:

UINavigationController (for registration)

if (registration == success) switch for main logic NavigationController

Need:

UINavigationController (for registration)

if (registration == success) switch for TabbarController with (UINavigationController1, UINavigationControlle2)

Upvotes: 0

Views: 41

Answers (1)

gabbler
gabbler

Reputation: 13766

You can use UITabBarController setViewControllers function, the parameter is a NSArray.

NSString *containerName = @"tabBar";
UITabBarController *root = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:containerName];

UIWindow *wnd = [[[UIApplication sharedApplication] delegate] window];
wnd.rootViewController = root;
[wnd makeKeyAndVisible];

After successfully registration, switch to the tabBarController which has an identifier "tabBar".

Upvotes: 1

Related Questions