2016-07-28 3 views
1

UIAlertControllerからボタンを押した後に、メール作成ビューコントローラをプルアップしようとしています。シミュレータでは、メールを開こうとするとシミュレータでいつものクラッシュとエラーメッセージが表示されますが、アプリでは何も得られません。コントローラーなし、クラッシュなし、何もありません。ここにコードがあります。メール作成コントローラがUIAlertControllerから開かない

[actionSheet addAction:[UIAlertAction actionWithTitle:@"Email" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 

     [self emailThem]; 

     [self dismissViewControllerAnimated:YES completion:^{ 
     }]; 
    }]]; 

-(void) emailThem { 
    NSLog(@"EMAIL"); 
    MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init]; 
    mail.mailComposeDelegate = self; 
    [mail setSubject:@"To P3 Media"]; 
    [mail setMessageBody:@"Replace this text with your message for all the information you would like on P3 Media." isHTML:NO]; 
    [mail setToRecipients:@[@"[email protected]"]]; 

    [self presentViewController:mail animated:YES completion:NULL]; 
} 

何が問題ですか?

+0

を試してみてはビューコントローラを却下した後、「[自己emailThem]」完了ハンドラの内部に入れてみてください。また、emailThemメソッドの下にあるpresentViewControllerがユーザインタフェーススレッド上で実行されていることを確認してください。 –

+0

@SeanMcDonald [OK]私はそれを試みた '[自己dismissViewControllerAnimated:はい完了:^ { [self emailThem]; }];でも、それと同じことです。 – user717452

+0

デバイスに電子メールアカウントが設定されていますか? –

答えて

0

このコード

[actionSheet addAction:[UIAlertAction actionWithTitle:@"Email" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 

    [self emailThem]; 

    [self dismissViewControllerAnimated:YES completion:^{ 
    }]; 
}]]; 

-(void) emailThem { 
    NSLog(@"EMAIL"); 
    MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init]; 
    mail.mailComposeDelegate = self; 
    [mail setSubject:@"To P3 Media"]; 
    [mail setMessageBody:@"Replace this text with your message for all the information you would like on P3 Media." isHTML:NO]; 
    [mail setToRecipients:@[@"[email protected]"]]; 
    dispatch_async(dispatch_get_main_queue(),^{ 
     [self presentViewController:mail animated:YES completion:NULL]; 
    }); 
} 
関連する問題