【问题标题】:IOS 6 Xcode 4.5 MFMailComposer CrashIOS 6 Xcode 4.5 MFMailComposer 崩溃
【发布时间】:2013-06-05 18:26:28
【问题描述】:

我已将 XCode 更新到 4.5,现在如果我按下按钮发送电子邮件,电子邮件功能会崩溃。

我做错了什么?

我已经在我的头文件中实现了 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 =@"Youtube@gmail.com";
    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];



    }

【问题讨论】:

  • 不确定,但试试 [self presentModalViewController:composer animated:YES completion:nil]; (添加了“模态”)
  • 您好,谢谢您的回答。但这不起作用。我认为 Modal 是旧版本
  • 完全相同的代码对我有用
  • 我解决了我的问题。 uitableview 的背景图片在我的 appdelegate 中存在问题...
  • @user1355961 您能否详细说明您找到的解决方案?背景图片对发送电子邮件有何影响?

标签: xcode crash ios6 mfmailcomposer


【解决方案1】:

您需要在此委托方法中编写以下代码

- (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];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-22
    • 1970-01-01
    • 1970-01-01
    • 2012-09-13
    • 1970-01-01
    • 1970-01-01
    • 2015-09-05
    • 1970-01-01
    相关资源
    最近更新 更多