Tom Shen
Tom Shen

Reputation: 2028

How to set the selected item of UITabBar by code

I have a tab bar controller linking 3 view controllers. On controller A, I have a button linking to controller C. But when I use segue or presentViewController:animated:completion: it will show controller C but won't update the tab bar item. Is there a way to make it update by code so the user won't have to press it to get it to work properly. Thanks.

Upvotes: 1

Views: 214

Answers (1)

Leo
Leo

Reputation: 24714

You can use setSelectedIndex of UITabBarController

[self.tabBarController setSelectedIndex:2]

Upvotes: 2

Related Questions