【问题标题】:how to email,share and print pdf? [closed]如何通过电子邮件发送、共享和打印 pdf? [关闭]
【发布时间】:2014-09-11 17:53:52
【问题描述】:

我正在开发一个 iOS 应用程序。我是 iOS 文件操作的新手。我想通过电子邮件发送、共享和打印每个 pdf 文件。那些 pdf 文件是捆绑在一起的。

在我的视图控制器中,我创建了 3 个按钮:

  1. 电子邮件
  2. iBooks
  3. 打印

我应该怎么做才能实现这些操作?

【问题讨论】:

  • 将 SLComposeViewController 用于email support
  • You question is way too broad。在问这里之前,您是否尝试过使用谷歌搜索教程/示例?如果是这样,您尝试了什么?
  • 我使用了 UIDocumentInteractionControllerDelegate,它解决了我的问题。

标签: ios objective-c pdf share


【解决方案1】:

这可能对您的电子邮件有帮助:

首先,在你的应用程序中导入MessageUI.framework。

您的设备或模拟器必须配置有您的电子邮件帐户之一。

然后,您的电子邮件按钮单击事件将如下所示:

-(void)ClickOnEmailUs
{
    MFMailComposeViewController *picker;
    picker = [[MFMailComposeViewController alloc] init];
    if(picker)
    {
        if ([MFMailComposeViewController canSendMail])
        {
            picker.mailComposeDelegate = self;
            [picker setToRecipients:receipientsArrayOfStrings];
            [picker setSubject:@"Your Subject"];
            [picker setMessageBody:@"E-Mail Body" isHTML:YES];
            [picker addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"file.pdf"];  // for adding attachment to the mail
            [self.navigationController  presentModalViewController:picker animated:YES];
        }
        else
        {
            UIAlertView *noEmailAccountMsg = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Please configure your email account." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [noEmailAccountMsg show];
        }
    }
}

【讨论】:

  • 在显示 MFMailComposer 之前将此行添加到上面的代码中。 [vc addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"file.pdf"];这将有助于附件
猜你喜欢
  • 1970-01-01
  • 2018-09-19
  • 1970-01-01
  • 2021-04-05
  • 2023-03-06
  • 1970-01-01
  • 2012-04-11
  • 2015-06-21
  • 2023-03-10
相关资源
最近更新 更多