1

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.

phidah
  • 5,794
  • 6
  • 37
  • 58

3 Answers3

2

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
  • 26,829
  • 3
  • 55
  • 74
0

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

Mehar
  • 61
  • 1
  • 8
0

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
  • 1,031
  • 8
  • 20