2013-06-19 5 views
0

MFMailComposeViewController 표시하지 않고 내 코드iOS6의 : MFMailComposeViewController가 같은 코드는 iOS6의 에서 일하고 같은 곳 iOS6의에서 제시하지

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:가 아이폰 OS 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]; 

}