iphone change tab bar item on button click
I have 4 tabs in my iphone application. W开发者_JS百科hen user will click a button in tab-1, I want to move/switch user to another tab suppose tab-2.
How to do that?
You can use
[self.tabBarController setSelectedIndex:tabIndex];
where tabIndex
is the index of the tab you want to switch to.
Might also point out that if you are inside a view, you should use super instead of self.
Swift 3.0 version of @Jasarien answer:
self.tabBarController?.selectedIndex = tabIndex
where tabIndex
is the index of the tab you want to switch to.
精彩评论