1

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



    }
4

1 に答える 1

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];
}
于 2013-06-05T09:23:33.977 に答える