如果返回no,MFMailComposeViewController canSendMail更改警报

时间:2011-11-11 11:01:03

标签: iphone objective-c ios cocoa-touch ipad

我在我的应用程序中使用MFMailComposeViewController canSendMail一切正常但如果iPhone或iPad上没有帐户,它会返回标准的alertview我想要更改的内容。如果我在其他地方发出警报,它将返回2个警报。有没有办法改变它返回的标准警报?或者至少改变其中的文字?

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

}

3 个答案:

答案 0 :(得分:13)

尝试一件事..将您的MFMailComposeViewController初始化代码移到canSendMail块中。

答案 1 :(得分:4)

在if:

中移动'MFMailComposeViewController'的alloc
if ([MFMailComposeViewController canSendMail]) {
    MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
    controller.mailComposeDelegate = self;
    controller.navigationBar.tintColor = [UIColor grayColor];
    NSArray *toRecipients = [NSArray arrayWithObject:@"info@info.nl"];
    [controller setToRecipients:toRecipients];
    [controller setSubject:@"bericht van info"];
    [self presentModalViewController:controller animated:YES];
    [controller release];
} else {
    // Display custom alert here.
}

答案 2 :(得分:0)

您可以检查设备是否可以使用

发送电子邮件

[MFMailComposeViewController canSendMail]

如果没有,请在旁边显示对话框