我想在我的电子邮件中集成一个按钮,这样当用户从桌面浏览器点击它时,该按钮就会在浏览器中打开。
如果用户正在通过移动设备查看,则应在应用程序中打开。
我该怎么做?
答案 0 :(得分:0)
你可以尝试这个: 不要忘记申报其代表。
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController * emailController = [[MFMailComposeViewController alloc] init];
emailController.mailComposeDelegate = self;
[emailController setSubject:subject];
[emailController setMessageBody:mailBody isHTML:YES];
[emailController setToRecipients:recipients];
[self presentViewController:emailController animated:YES completion:nil];
[emailController release];
}
// Show error if no mail account is active
else {
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"You must have a mail account in order to send an email" delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"OK") otherButtonTitles:nil];
[alertView show];
[alertView release];
}