views:

262

answers:

2

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?

+2  A: 

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

Diederik Hoogenboom
A: 

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

Morion