用户点击cell
后,我会在一些代码之后执行此操作:
[self.window.rootViewController presentModalViewController:mailer animated:YES];
然后当他点击取消按钮或发送此方法时:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[[((UIViewController *)(self.superview.superclass)) presentedViewController] dismissModalViewControllerAnimated:NO];
}
但是我的应用程序崩溃了并且出去了。
012-12-17 18:52:09.243 testapp[8293:15203] Mail cancelled: you cancelled the operation and no email message was queued
2012-12-17 18:52:09.243 testapp[8293:15203] +[UIResponder presentedViewController]: unrecognized selector sent to class 0xbb5db0
2012-12-17 18:52:09.244 testapp[8293:15203] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIResponder presentedViewController]: unrecognized selector sent to class 0xbb5db0'
*** First throw call stack:
(0x1ba6022 0x1688cd6 0x1ba7aad 0x1b0ced0 0x1b0ccb2 0x4e466 0xa99bf 0xac64f 0xa63f2 0x8d05af 0x1ba7e99 0x50f14e 0x50f0e6 0x5b5ade 0x5b5fa7 0x5b5266 0x5343c0 0x5345e6 0x51adc4 0x50e634 0x1d39ef5 0x1b7a195 0x1adeff2 0x1add8da 0x1adcd84 0x1adcc9b 0x1d387d8 0x1d3888a 0x50c626 0x370d 0x26c5 0x1)
答案 0 :(得分:0)
只需尝试[self dismissViewControllerAnimated:NO completion:nil]
答案 1 :(得分:0)
如果你试图解雇VC,那么这应该有效:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissModalViewControllerAnimated:NO];
}
答案 2 :(得分:0)
尝试[controller dismissModalViewControllerAnimated:NO];
答案 3 :(得分:0)
崩溃的原因是presentViewController仅存在于iOS 5及更高版本上。如果您在iOS 4上运行它会导致您显示的异常。
dismissModalViewController是解除用iOS4 + 5的presentModalViewController提供的控制器的正确方法。它仍适用于iOS 6但不推荐使用。你在那里提出了ViewController和dismissViewController。