如果不在MFMailComposeViewController 9模拟器中抛出致命错误,我就无法让iOS打开。
同样的代码(目标C)在iOS 8.x和更低的版本中运行得非常完美,但是今天我安装了Xcode 7 beta 5,当我在iOS 9模拟器上运行该应用程序时,我得到了一个名为"MailCompositionService意外退出“的对话框,当我查看错误报告时,我看到:
应用程序特定信息:*由于未识别的异常“NSInvalidArgumentException”终止应用程序,原因:-_NSArrayI isEqualToString::未识别的选择器发送到实例0x7fd314280b10‘ 终止类型为NSException abort(),称为CoreSimulator 179 -设备: iPhone 6-运行时: iOS 9.0 (13A4325c) - DeviceType: iPhone 6
当邮件组合视图出现时,会发生错误。它冻结几秒钟,然后出现错误对话框。
打开邮件组合视图的代码是:
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Comment title"];
[picker setMessageBody:@"Comment description" isHTML:NO];
[self.window.rootViewController presentModalViewController:picker animated:YES];
[picker release];
}如果这有助于了解,在应用程序崩溃之前,mailComposeController:didFinishWithResult:error:是用result = MFMailComposeResultCancelled和error = nil调用的。
我很想知道如何找出这个错误的原因。谢谢!
发布于 2015-10-06 16:00:25
问题是在模拟器上,在真正的设备上邮件编写器是正确工作的。
发布于 2016-04-07 05:16:06
根据苹果开发者论坛,更多细节是here。
模拟器不支持邮件。您可能应该尝试在设备中测试邮件功能。
发布于 2015-08-19 01:47:12
您应该使用:[self.window.rootViewController presentViewController:picker animated:YES completion:NULL]; presentModalViewController被废弃,因为ios6是并已被presentViewController:animated:completion: ( ie:- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated NS_DEPRECATED_IOS(2_0, 6_0); )所取代。
https://stackoverflow.com/questions/32078073
复制相似问题