Manni
Manni

Reputation: 11148

presentModalViewController: how to interact with parent

Showing a modal ViewController works fine:

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myView];
[self.navigationController presentModalViewController:navController animated:YES];
[navController release];    

In my modal view, I have a navigation button to switch back to the mainmenu. Normally a would call [self.navigationController popToViewController:delegate.viewMainmenu animated:YES]; but thats not possible inside the modal view. How can I interact with the "parent" to call him that he calls popToViewController?

Thanks a lot!

Upvotes: 2

Views: 4103

Answers (2)

Eric
Eric

Reputation: 3895

If you are asking how to dismiss the modal view controller, you'll want the modal view itself to call:

[self dismissModalViewControllerAnimated:YES];

Upvotes: 0

Max
Max

Reputation: 16719

use property parentViewController in your modal vc and call [self.parentViewController dismissModalViewControllerAnimated: YES];

Upvotes: 4

Related Questions