views:

27

answers:

1

Hi

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.

A: 

Have you tried:

self.tabBarController.selectedIndex = 1;

in the first viewController?

ChrisB
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.
Structurer