0
votes

I have a viewController with 4 buttons (HomePage) and then a TabBarController with 3 viewControllers. One of the TabBarController's viewControllers I want to be used as a way to get back to the "HomePage" via a tabBar icon. I have associated a custom class that I created called "HomeViewController" to that viewController. See diagram below

enter image description here

HomeViewController .H file. I have created a protocol with a method "returnToHomepage"

enter image description here

HomeViewController .M file As soon as the view is loaded it calls the delegate. enter image description here

In my HomepageViewController .H file I have made sure that the file adheres the protocol. enter image description here

HomepageViewController .M file

I instantiate an instance of HomeViewController and set delegate to self but returnToHomePage method never gets called! Not sure what I'm missing... enter image description here

2

2 Answers

1
votes

I think that your're calling the delegate method before the delegate is set.

When you call alloc-init on the controller, it initializes and ViewDidLoad is called,... and THEN you set the delegate... so this

[self.delegate returnToHomepage];

is called before

homeVC.delegate = self;
1
votes

The HomeViewController you're creating in viewDidLoad is not the same one that's actually being presented onscreen. You'll need to access it with your UITabBarController's viewControllers method and set it's delegate that way.