2012-10-05 54 views
1

我已经更新XCode到4.5,现在电子邮件功能崩溃,如果我按下按钮发送电子邮件。IOS 6 Xcode 4.5 MFMailComposer崩溃

我做错了什么?

我已经实现了MessageUI.framework在我的头文件

#import <UIKit/UIKit.h> 
#import <MessageUI/MessageUI.h> 

@interface ImpressumViewController : UIViewController <MFMailComposeViewControllerDelegate> 

这里是我的按钮代码:

- (IBAction)kontakt:(id)sender { 

    MFMailComposeViewController *mailcontroller = [[MFMailComposeViewController alloc] init]; 
    [mailcontroller setMailComposeDelegate:self]; 
    NSString *email [email protected]"[email protected]"; 
    NSArray *emailArray = [[NSArray alloc] initWithObjects:email, nil]; 
    [mailcontroller setToRecipients:emailArray]; 
    [mailcontroller setSubject:@"Youtube Tutorials"]; 
    [self presentViewController:mailcontroller animated:YES completion:nil]; } 

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



    } 
+0

不确定,但尝试[self presentModalViewController:composer animated:YES completion:nil]; (增加了“Modal”) – Romo

+0

嗨,谢谢你的回答。但这不起作用。我认为莫代尔是旧版本 – user1355961

+0

完全相同的代码适用于我 –

回答

0

你需要编写遵循此委托方法的代码

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ switch (result) 
    { 
     case MFMailComposeResultCancelled: 
      NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued"); 
      break; 
     case MFMailComposeResultSaved: 
      NSLog(@"Mail saved: you saved the email message in the Drafts folder"); 
      break; 
     case MFMailComposeResultSent: 
      NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send the next time the user connects to email"); 
      break; 
     case MFMailComposeResultFailed: 
      NSLog(@"Mail failed: the email message was nog saved or queued, possibly due to an error"); 
      break; 
     default: 
      NSLog(@"Mail not sent"); 
      break; 
    } 

    //[self dismissModalViewControllerAnimated:YES]; 
}