views:

738

answers:

3

I have a UITabBar with a number of UITabBarItems. I've assigned a different view controller to each of these.

I want to load some data etc., when each button is clicked. Therefore I will like to know where to put that code? I tried implementing viewWillAppear and viewDidLoad in the view controller but those didn't get called.

A: 

I know that when you assign a delegate to a UINavigationController, the component UIViewController delegate methods are not called. It seems likely that the same is true of UITabBarController.

I would try implementing the UITabBarControllerDelegate protocol and implementing the tabBar:didSelectViewController: method.

Alex
A: 

Are you sure your custom controllers inherit from UIViewController?

Don't forget the signature for the viewWillAppear is viewWillAppear:animated:

I'm working off the beta 5 right now, and it works just fine (I'm also using a TabBar).

Oli
A: 

Write your code in viewdidappear function.but i didn't try

uwillneverknow