Reputation: 145
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 {
}
Upvotes: 10
Views: 4558
Reputation: 17478
try one thing.. Move your MFMailComposeViewController initialization code inside the canSendMail
block.
Upvotes: 13
Reputation: 69459
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.
}
Upvotes: 4
Reputation: 5093
You can check if the device can send emails with
[MFMailComposeViewController canSendMail]
And, if not, show the dialog in your side
Upvotes: 0