I have a project similar to Apple's PageControl example. I have a UIViewController "PhotoViewController" which contains a UIScrollView and a UIToolbar. The UIScrollView loads another XIB and UIViewController "PhotoScrollViewController".
In PhotoScrollViewController, I have a UIButton which displays an image. I have an IBAction on this button, and I would like to click on it to show/hide the UIToolbar in PhotoViewController.
In PhotoViewController.h I have
@interface PhotoViewController : UIViewController <UIScrollViewDelegate> {
IBOutlet UIToolbar *toolBar;
..
}
@property (nonatomic, retain) UIToolbar *toolBar;
I have tried a few things in PhotoScrollViewController, such as importing PhotoViewController.h in PhotoScrollViewController.h and adding it to the interface, then attempting to access it through my function like:
@implementation PhotoScrollViewController
- (IBAction)toggleMenu {
photoViewController.toolBar.hidden = NO;
}
But this doesn't work. I've also tried removeFromSuperView, and self.parentViewController, and some other things. I am not sure how to make this toolbar hidden (I've tried alpha as well, I just can't access the toolbar at all).
I tried adding a function to PhotoViewController instead, using toolBar.hidden = YES. This works if I execute the function from PhotoViewController, but it doesn't work if I access it from PhotoScrollViewController (with PhotoViewController *photoViewController in .h):
@implementation PhotoScrollViewController
- (IBAction)toggleMenu {
photoViewController.toolBar.hidden = NO;
[photoViewController toggleTopMenu];
[[PhotoViewController alloc] toggleTopMenu];
}
@implementation PhotoViewController
- (IBAction)toggleTopMenu {
toolBar.hidden = NO;
}
I also tried adding the toolbar to PhotoScrollViewController instead, and I can toggle it, but I can't figure out how to tell the main UIViewController to dismiss PhotoViewController... so whichever way I attack this problem I don't know how to communicate properly between UIViewControllers.. and the documentation I read seems to follow what I've tried.