Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
811 views
in Technique[技术] by (71.8m points)

objective c - MFMailComposeViewController throws an error only in iOS 9

I can't get MFMailComposeViewController to open without throwing a fatal error in iOS 9 Simulator.

The same code (Objective C) works flawlessly in iOS 8.x and lower but today I installed Xcode 7 beta 5 and when I run the app on iOS 9 Simulator, I get a dialog box titled "MailCompositionService quit unexpectedly" and when I view the error report, I see:

Application Specific Information: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x7fd314280b10'

terminating with uncaught exception of type NSException abort() called CoreSimulator 179 - Device: iPhone 6 - Runtime: iOS 9.0 (13A4325c) - DeviceType: iPhone 6

The error happens when the mail composition view comes up. It freezes for a few seconds and then the error dialog box comes up.

The code that opens the mail composition view is:

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];
}

If it helps to know, before the app crashes, mailComposeController:didFinishWithResult:error: is called with result = MFMailComposeResultCancelled and error = nil.

I'd appreciate tips on how to find the cause of this error. Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The issue is with simulator, on the real device mail composer is working correctly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...