我使用以下代码来关闭模态视图控制器:
- (IBAction)done {
#ifdef __IPHONE_5_0
if ([self respondsToSelector:@selector(presentingViewController)])
[self.presentingViewController dismissModalViewControllerAnimated:YES];
else
#endif
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
如果我使用iOS 4.3 iPad嘲笑他的模拟器,它使用self.parentViewController
并且工作正常。但是,当我使用iOS 6.0 iPad来模拟他时,模拟器在使用self.presentingViewController
解除视图后立即崩溃。
我没有真正的iPad来测试......有什么想法吗?
编辑:
下面的是创建模态视图控制器的代码。
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];
答案 0 :(得分:3)
一些事情:
dismissViewControllerAnimated:completion:
作为@rdelmar说self
,如果需要,它会将此消息转发给演示控制器。答案 1 :(得分:1)
dismissModalViewControllerAnimated:已弃用,请使用dismissViewControllerAnimated:completion:而不是。