0
votes

This has really been pissing me off for a while now, and I have no idea how to get further. I have created a tabbed application hence getting the default UITabBarController + 2 View controllers that are nested within this. Fair enough. Now I noticed the viewcontrollers viewDidLoad methods wasn't called when switching around. Ok, so I find theres a tabbar delegate for when a viewcontroller gets "tabbed." Now my problem is the delegate method which I've placed in AppDelegate, is not being called. I have tried in all ways I know of to make a reference to the given tabbarcontroller (to se the delegate programmatically) and I have tried ctrl-dragging the delegate to anywhere possible. Am I doing sth wrong? (because everywhere I look this seems to not be a problem, and people are holding reference to their tabbars).

Thanks

2

2 Answers

0
votes

You have to set your view controller's class in storyboard if you want to be able to make references. Select your view controller in storyboard. On the right panel go to Identity inspector and in the Class field set the name of the class. The you should be able to make references and also viewDidLoad should be called.

enter image description here

0
votes

I used this code to get a reference to the tabbar, so I could set the delegate programmatically:

UITabBarController *tabBar = ((UITabBarController*)self.window.rootViewController).delegate = self;

Very simple, I guess I was running late night hours yesterday. Yet the issue was clearly using storyboard and then trying to make an outlet in app delegate (I still dont think that is possible).