I got dismissModalViewControllerAnimated to work properly on the following setup but am confused as to why it works on self (the modalViewController) rather than the parentViewController.
Here's the setup:
- I have a UITableViewController with a nav button that calls up a modal view:
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Root";
_data = [NSArray arrayWithObjects:@"One", @"Two", nil];
_detailController = [[DetailViewController alloc] init];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showAbout)];
}
- (void)showAbout
{
AboutViewController *abv = [[AboutViewController alloc] init];
abv.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:abv animated:YES];
}
Here's the modal view controller AboutViewController with a toolbar button that triggers a dismiss action to close the modal:
- (IBAction)dismissAction:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
My question is why does [self dismissModalViewControllerAnimated] work rather than [self.parentViewController dismissModalViewControllerAnimated] ?? Is this new in iOS 5? I thought only the parentViewController is capable of dismissing a child modal view?
Thanks!