MFMailComposeViewController - iPad

前端 未结 5 1661
失恋的感觉
失恋的感觉 2020-12-28 13:46

I\'ve setup a MFMailComposeViewController and it works just fine on the iPhone, but on the iPad it crashes, saying:

*** Terminating app due to uncaught excep         


        
5条回答
  •  -上瘾入骨i
    2020-12-28 14:01

    It's happen b'cause of your iOS default mail app did't configured yet with any mail id. so configure with any of your mail id and try.

    like this

    if ([MFMailComposeViewController canSendMail]){
        MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
        controller.mailComposeDelegate = self;
        [controller setToRecipients:[NSArray arrayWithObject:eMail]];
        [self presentViewController:controller animated:YES completion:nil];
    }
    else{
        UIAlertView *anAlert = [[UIAlertView alloc] initWithTitle:@"error" message:@"No mail account setup on device" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
        [anAlert addButtonWithTitle:@"Cancel"];
        [anAlert show];
    }
    

    hope its help you.

提交回复
热议问题