0

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

苏米特

4

1 回答 1

2

试试 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];
}


  }
于 2012-05-01T04:17:03.780 回答