2015-12-13 29 views
0

所以我知道我將不得不使用MFMailComposeResultSent。 (至少我認爲這就是我應該使用的)這是我有的代碼,它發送電子郵件和一切正常,但郵件作曲者保持。使MFMailComposeViewController在發送時消失

編輯:這裏是我的代碼

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:@"[email protected]"]; 
    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]; 
} 

回答

1

您需要設置SuperLovedEmail對象的mailComposeDelegate屬性爲self,然後處理didFinishWithResult消息,像這樣:

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

你可能發現評估MFMailComposeResult以查看實際發送是否有用。

相關問題