die*_*men 6 pdf email objective-c ibooks uiactivityviewcontroller
我的应用程序中存在问题.在获得一些统计数据之后,我生成了一个PDF文件,我想要显示一个UIActivityViewController主要有"在iBooks中打开"和"通过邮件发送"选项(其他像"在Dropbox中打开"会很棒).
那就是在尝试使用UIActivityViewController之前,我使用的是UIDocumentInteractionController,其代码如下:
self.docController = [UIDocumentInteractionController interactionControllerWithURL:url];
self.docController.delegate = self;
[_docController presentOpenInMenuFromRect:_openInIBooksButton.bounds inView:self.openInIBooksButton animated:YES];
Run Code Online (Sandbox Code Playgroud)
其中url是/Documents/../statistics.pdf之类的路径.它工作,它显示了一个弹出窗口,按钮在iBooks中打开并在Dropbox中打开,但不是Send by Mail.现在我用以下代码更改了它:
NSArray* itemsToShare = [NSArray arrayWithObjects:pdfData, nil];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypeCopyToPasteboard]; //or whichever you don't need
[self presentViewController:activityVC animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
其中pdfData是NSData对象.它也有效,但现在它显示了通过电子邮件发送它的选项,但不是iBooks选项.我疯了,因为我没有找到这种行为的原因,我需要两个选项,iBooks和Mail.
我不知道它是否与UIDocumentInteractionController有一个以.pdf结尾的路径并且UIActivityViewController只有一个NSData对象这一事实有关.但我无法找到解决方案.
有人之前发现了这个问题吗?
非常感谢你.
rma*_*ddy 10
当您使用时,presentOpenInMenuFromRect:inView:animated:
您只会获得可以使用给定文件的应用程序列表.
您想要使用的是presentOptionsMenuFromRect:inView:animated:
为您提供所需的选项.
归档时间: |
|
查看次数: |
5644 次 |
最近记录: |