views:

69

answers:

1

I'm trying to programmatically switch tabs. I tried to do this using the following calls:

tabBarController.selectedIndex = 2;
tabBarController.selectedViewController = checkinViewController;


In both cases, This is what I get:

alt text

This is what I want:

alt text


Any clue?

+1  A: 

Assigning a new view controller to this property changes the currently displayed view and also selects an appropriate tab in the tab bar. Changing the view controller also updates the selectedIndex property accordingly.

Maybe just try without the selectedIndex? Also, is there a fourth tab item in there? If there's only 3, then selectedIndex = 2 would be the more button and:

Attempting to set this value to an index of a view controller that is not visible in the tab bar, but is instead managed by the More navigation controller, has no effect.

Some thoughts, not sure if this is the answer.

Typeoneerror
That second quote solved it. I was showing an UIActionSheet from the tabbar, and was calling the tab switch when that sheet was shown (while tabbar is not visible). Thanks!
Sam V