Ternary
Ternary

Reputation: 2411

UITabViewController Tab Identification

I have a simple iPhone app (modified from the UITabBarController project template) where each tab is a different set of data using the same view controller (similar to the iPod app).

So for example if each tab was a person's name and hitting it would display their friends. Then each tab would use the same view controller right?

My question now is how do I identify programmatically what tab just got pressed (and in what function) so I know to load the appropriate data. I see viewDidLoad called each time but how do I know what tab?

Upvotes: 0

Views: 567

Answers (2)

Morion
Morion

Reputation: 10860

You can use UIToolbar instead. You can insert some UIBarButtonItems there. So you will know, what button has been clicked.

Upvotes: 0

diederikh
diederikh

Reputation: 25281

UITabBarController has a selectedIndex method which returns the index of the selected tab.

Upvotes: 2

Related Questions