Iphone – UITabBarController is possible to select the tab via code

iphoneuitabbarcontroller

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?

Best Answer

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];