我是新来的,

我的 viewController 中有这段代码,

- (void)sendMail:(id)sender {
    NSArray *to = [NSArray arrayWithObjects:@"[email protected]", nil];

    mailComposer = [[MFMailComposeViewController alloc] init];
    mailComposer.mailComposeDelegate = self;
    [mailComposer setToRecipients:to];
    [mailComposer setSubject:@"Test Mail"];
    [mailComposer setMessageBody:@"Testing message body" isHTML:NO];
    [self presentModalViewController:mailComposer animated:YES];
}



#pragma mark - mail compose delegate
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
    if(result) {
        NSLog(@"Result = %d", result);
    }
    if(error) {
        NSLog(@"Error = %@", error);
    }
    [self dismissModalViewControllerAnimated:YES];
}

但是当我单击 Controller 中的发送按钮时,出现错误,例如,



问题是什么?

最佳答案

您的代码没有任何问题。 MFMailComposeViewController 不适用于模拟器,请在真实设备中尝试相同的代码。

关于ios - MailCompositionService 意外退出 ios,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39327614/

10-13 03:50