0

I have a UITabBarController that controls two tabs, Main and Settings.

Now I would like, under certain conditions, to switch from the Main tab to the Settings tab (like if there is a setting the user have to do before he can use the App).

I know I can do this from the AppDelegate, but my condition could occur when I'm running in the Main view.

I have tried something like this:

    AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
delegate.rootController.selectedIndex = 1;

Where rootController is a UITabBarController defined in my AppDelegate.

The result from above code is that the tab change (eg the Settings tab is showed as active) but it still shows the Main view.

I'm sure there is a simple solution to this that I must have missed...

All suggestions are appreciated.

1 Answer 1

2

Have you tried:

self.tabBarController.selectedIndex = 1;

in the first viewController?

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Have tried it. Have #import "AppDelegate.h" but still get the warning "Request for member "rootController" in something not a structure or union" when building.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.