2013-06-19 4 views
0

MFMailComposeViewController не представляя в iOS6, где в тот же код работает в iOS6 и мой кодiOS6: MFMailComposeViewController не отображается

if ([MFMailComposeViewController canSendMail]) 
    { 
     searchView.hidden=YES; 
     MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
     picker.mailComposeDelegate = self; 
     [picker setSubject:[NSString stringWithFormat:@"Query from ccc App"]]; 
     NSArray *toarr =[[NSArray alloc]initWithObjects:@"[email protected]", nil]; 
     [picker setToRecipients:toarr]; 
     [self presentModalViewController:picker animated:YES];   
    } 
+2

Вы используете это на устройстве с учетной записью электронной почты? –

ответ

1

presentModalViewController:animated: осуждается в прошивкой 6.0.

Вместо этого использовать presentViewController:animated:completion:.

1
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; 
mc.mailComposeDelegate = self; 
[mc setSubject:emailTitel]; 
[mc setMessageBody:message isHTML:NO]; 
[mc setToRecipients:empfaenger]; 

[self presentViewController:mc animated:YES completion:NULL]; 

} 

-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { 

switch (result) { 
    case MFMailComposeResultCancelled: 
     NSLog(@"Email cancelled"); 
     break; 
    case MFMailComposeResultFailed: 
     NSLog(@"Email failed with error: %@", [error localizedDescription]); 
     break; 
    case MFMailComposeResultSaved: 
     NSLog(@"Email saved"); 
     break; 
    case MFMailComposeResultSent: 
     NSLog(@"Email sent"); 
     break; 
    default: 
     break; 
} 

[self dismissViewControllerAnimated:YES completion:NULL]; 

}

Смежные вопросы