I am using the following code to dismiss modal view controllers:
- (IBAction)done {
#ifdef __IPHONE_5_0
if ([self respondsToSelector:@selector(presentingViewController)])
[self.presentingViewController dismissModalViewControllerAnimated:YES];
else
#endif
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
If I runt he simulator using iOS 4.3 iPad, it uses self.parentViewController and works fine. However, when I runt he simulator using iOS 6.0 iPad the simulator crashes right after the view is dismissed using self.presentingViewController.
I do not have an actual iPad to test on… any ideas?
EDIT:
below is the code that creates the modal view controller.
NSArray* errors = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Errors" ofType:@"plist"]];
UIViewController* vc;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
DocumentsViewController_iPad* docsVC = [[DocumentsViewController_iPad alloc] initWithNibName:@"DocumentsViewController-iPad" bundle:nil];
docsVC.documents = errors;
docsVC.errors = YES;
docsVC.navTitle = @"Troubleshooting";
vc = docsVC;
} else {
DocumentsViewController* docsVC = [[DocumentsViewController alloc] initWithNibName:nil bundle:nil];
docsVC.documents = errors;
docsVC.errors = YES;
docsVC.navTitle = @"Troubleshooting";
vc = docsVC;
}
vc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:vc animated:YES];
[vc release];
A few things:
dismissViewControllerAnimated:completion:as @rdelmar saidself, it will forward this message to the presenting controller if needed.