ios - 在 ios 中与 inapp 电子邮件作斗争

标签 ios

我是 iOS 的新手,正在尝试在我的应用程序中添加不恰当的电子邮件。我有一个屏幕,在其中按下电子邮件图标应该会打开 inapp 电子邮件。我有 inapp 电子邮件的代码。但是,按钮已经是 Controller 上的 socket 。所以,我不知道如何将同一个按钮链接到具有 inapp 电子邮件代码的不同类/文件。我正在考虑设置一个委托(delegate),但不知道如何在邮件类中初始化委托(delegate)。已经苦苦挣扎了几天...请帮忙!

提交

最佳答案

试试 MFMailComposeViewController.... 下面是一些示例代码: 确保导入 MEssageUI 框架并在 .h 中导入 MFMailComposeViewController/MessageUI 并符合其委托(delegate)

            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/

相关文章:

objective-c - 动态填充 iPhone 中的数据

ios - BRAOfficeDocumentPackage 未声明的类型

android - 无法将没有 CSS 节点的子节点添加到没有测量功能的节点

ios - Swift 是否可以为 MKLocalSearchRequest 和 MKLocalSearchResponse 设置一个特定的国家

ios - 将 SkeneKit 场景捕获为视频

ios - GLSL 着色器编译但不在 Windows 上绘制任何东西

iOS:增加录制音频的音量

ios - 这是 Swift 编译器中的错误吗?

objective-c - UIViewController: [super init] 调用 [self initWithNibName bundle:]

iphone - 特定设备支持的最大操作系统