我在我的应用程序中使用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 {
}
答案 0 :(得分:13)
尝试一件事..将您的MFMailComposeViewController初始化代码移到canSendMail
块中。
答案 1 :(得分:4)
在if:
中移动'MFMailComposeViewController'的allocif ([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]
如果没有,请在旁边显示对话框