Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MFMailComposeViewController canSendMail change alert if returned no

I use MFMailComposeViewController canSendMail in my app everything works great but if there are no accounts on the iPhone or iPad it returns a standard alertview what I would like to change. If I put a alert in the else it will return 2 alerts. Is there a way to change the standard alert it returns? Or at least change the text in it?

MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
if ([MFMailComposeViewController canSendMail]) {
    controller.mailComposeDelegate = self;
    controller.navigationBar.tintColor = [UIColor grayColor];
    NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
    [controller setToRecipients:toRecipients];
    [controller setSubject:@"bericht van info"];
    [self presentModalViewController:controller animated:YES];
    [controller release];
}
else {

}
like image 214
Dawid Avatar asked Nov 11 '11 11:11

Dawid


Video Answer


2 Answers

try one thing.. Move your MFMailComposeViewController initialization code inside the canSendMail block.

like image 107
Ilanchezhian Avatar answered Nov 16 '22 02:11

Ilanchezhian


Move the alloc of the 'MFMailComposeViewController' inside the if:

if ([MFMailComposeViewController canSendMail]) {
    MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
    controller.mailComposeDelegate = self;
    controller.navigationBar.tintColor = [UIColor grayColor];
    NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
    [controller setToRecipients:toRecipients];
    [controller setSubject:@"bericht van info"];
    [self presentModalViewController:controller animated:YES];
    [controller release];
} else {
    // Display custom alert here.
}
like image 25
rckoenes Avatar answered Nov 16 '22 02:11

rckoenes