我是iOS的新手,正在尝试在我的应用程序中添加不兼容的电子邮件。我有一个屏幕,在其中按下电子邮件图标应打开Inapp电子邮件。我有inapp电子邮件的代码。但是,该按钮已经是控制器上的插座。因此,我不知道如何将相同的按钮链接到具有inapp电子邮件代码的其他类/文件。我当时正在考虑建立一个委托,但是不知道如何在邮件类中初始化委托。奋斗了几天...请帮助!
住友
最佳答案
尝试MFMailComposeViewController ....这是一些示例代码:
确保您导入MEssageUI框架,并在.h中导入MFMailComposeViewController / MessageUI,并且还遵循其委托
MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];
[mailView setMailComposeDelegate:self];
if ([MFMailComposeViewController canSendMail]) {
[mailView setSubject:@"Interesting Apple News Article!"];
NSString *mailString = [[NSString alloc] initWithFormat:@"Test!"];
[mailView setMessageBody:mailString isHTML:NO];
[mailView setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentModalViewController:mailView animated:YES];
[mailString release];
[mailView release];
} else
[mailView release];
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Mailing Error" message:[error localizedDescription] delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
[alert show];
[alert release];
[self dismissModalViewControllerAnimated:YES];
} else {
[self dismissModalViewControllerAnimated:YES];
}
}
关于ios - 在iOS中努力处理Inapp电子邮件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10393264/