I have a tabbar navigation controller, and I would like to set up a protocol in one view controller and set its delegate in another view controller. How would I get the view controller pointer of the delegating view controller to the delegate view controller?
A:
Something like:
MyDelegatingViewController *delegatingController = [myTabBarController.viewControllers objectAtIndex:0];
MyDelegateViewController *delegateController = [myTabBarController.viewControllers objectAtIndex:1];
delegatingController.delegate = delegateController;
Ole Begemann
2010-01-27 14:06:02
A:
Ole, thank you. Your post got me half way there. I didn't realize at first that viewControllers returns the Navigation Controller of the view controllers. Once I realized this, I can then drill into the child view controller of the navigation controller:
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
UINavigationController *navController = [appDelegate.tabBarController.viewControllers objectAtIndex:1];
myViewController = (MyViewController*)[navController topViewController];
self.myViewController.delegate = self;
franchismo
2010-01-28 18:49:09