Ohad Regev
Ohad Regev

Reputation: 5711

How to Set the Selected Item in a UITabBar From within the Code?

I'm implementing UITabBar in my app. I managed making it work by implementing UITabBarDelegate in my header file and using

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item

in my .m file (as explained in this tutorial).

Now, there are 3 scenarios in my app where I wish to set the selected UITabBarItem manually from within the code (and not based on user action):

Can anyone direct me to how this should be done?

Upvotes: 0

Views: 3909

Answers (1)

albertamg
albertamg

Reputation: 28572

The UITabBarController class has two properties for managing the selected tab, namely, selectedViewController and selectedIndex. Look into those in the reference.

Upvotes: 1

Related Questions