【问题标题】:making MFMailComposeViewController disappear upon sending使 MFMailComposeViewController 在发送时消失
【发布时间】:2015-12-13 00:36:29
【问题描述】:

所以我知道我必须使用 MFMailComposeResultSent。 (至少我认为这是我应该使用的)这是我拥有的代码,它可以发送电子邮件,一切都很好,但邮件编写器保持不变。

编辑:这是我的代码

    if ([condition  isEqual: @"Excellent"] && [MFMailComposeViewController canSendMail]) {
    NSString *emailBody = [NSString stringWithFormat:@"Product:%@    Make:%@   Year Manufactured:%@  Description:%@  Condition:Excellent Email:%@",inputProduct,inputMake,inputYear,inputDescript, inputEmail];
    NSArray *recipient = [NSArray arrayWithObject:@"LoveShackElectronics@gmail.com"];
    MFMailComposeViewController *SuperLovedEmail = [[MFMailComposeViewController alloc]init];
    [SuperLovedEmail setTitle:emailTitle];
    [SuperLovedEmail setToRecipients:recipient];
    [SuperLovedEmail setMessageBody:emailBody isHTML:NO];
    [SuperLovedEmail setUserActivity:false];
    [self presentViewController:SuperLovedEmail animated:YES completion:nil];

}
else {
    UIAlertController *emailAlert = [UIAlertController alertControllerWithTitle:@"Oh No!" message:@"Your Phone is not able to send an email currently or you have not chosen a condition. Please make sure you have chosen a condition and that you are signed in through Mail" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *emailAlertAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * emailAlertAction) {}];
    [emailAlert addAction:emailAlertAction];
    [self presentViewController:emailAlert animated:YES completion:nil];
}

【问题讨论】:

    标签: ios objective-c mfmailcomposeviewcontroller


    【解决方案1】:

    您需要将SuperLovedEmail 对象的mailComposeDelegate 属性设置为self,然后处理didFinishWithResult 消息,如下所示:

    - (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
        [controller dismissViewControllerAnimated:true completion:nil];
    }
    

    您可能会发现评估 MFMailComposeResult 以查看发送是否实际发生很有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多