Iphone tab bar tab when button is clicked

I have 4 tabs in my iphone application. When the user clicks the button in tab-1, I want to move / switch the user to another tab, assuming tab-2.

How to do it?

+3
source share
3 answers

you can use

[self.tabBarController setSelectedIndex:tabIndex];

where tabIndexis the index of the tab you want to switch to.

+12
source

You can also specify that if you are inside a view, you should use super instead of self.

+3
source

Swift 3.0 @Jasarien:

self.tabBarController?.selectedIndex = tabIndex

tabIndex - , .

0

Source: https://habr.com/ru/post/1738525/


All Articles