UITabBarController is possible to select the tab via code?

ronny picture ronny · May 7, 2009 · Viewed 25k times · Source

is it UITabBarController possible to select the tab in code?like UINavigationController we can use popViewController pop back to rootViewController instead of press the back button, so how can this implement in tabbarcontroller?

Answer

Gerco Dries picture Gerco Dries · May 7, 2009

Use the selectedIndex property on the UITabBarController. More information can be found in the UITabBarController Class Reference.

controller.selectedIndex = 4;

or use

[controller setSelectedIndex:4];