I have a Settings popover. I have a button (More Info) in that popover. When the user clicks on that button, I want to bring up another view and I want to dismiss the popover.
How do I do this from my More Info button that is actually inside the popover?
Current I have a function that handles the button press:
- (IBAction)showFullVersionInfo:(id)sender
{
[self dismissPopoverAnimated:YES];
parent.settingsPopover = nil;
//need to show more Info...
}
The parent holds a reference ‘settingsPopover’ to the popover and I want to clear it.
You don’t want to do this from inside the popover controller. The popover controller should manage only the contents of your popover, not how and when the popover is shown/hidden.
You can do such actions only in the parent controller. Hide the popover only from the controller which has shown it (and owns it).
Your question should actually be: how to tell the parent controller that the user has performed some action inside the popover?
And the answer is: delegate.
Define a delegate, implement it in your parent controller, pass it to your popover and in IBAction call delegate method.