简体   繁体   English

UIActivityViewController没有显示“在iBooks中打开”选项

[英]UIActivityViewController not showing “Open in iBooks” option

I have a problem in my app. 我的应用程序中存在问题。 After getting some statistics, I generate a PDF file, and I want to show an UIActivityViewController with the options "Open in iBooks" and "Send By Mail" mainly (others like "Open in Dropbox" would be great to). 在获得一些统计数据之后,我生成了一个PDF文件,我想要显示一个UIActivityViewController主要有“在iBooks中打开”和“通过邮件发送”选项(其他像“在Dropbox中打开”会很棒)。

Well the thing is that before trying to use UIActivityViewController, I was using UIDocumentInteractionController, with the following code: 那就是在尝试使用UIActivityViewController之前,我使用的是UIDocumentInteractionController,其代码如下:

self.docController = [UIDocumentInteractionController interactionControllerWithURL:url];
self.docController.delegate = self;
[_docController presentOpenInMenuFromRect:_openInIBooksButton.bounds inView:self.openInIBooksButton animated:YES];

Where url is a path like /Documents/../statistics.pdf. 其中url是/Documents/../statistics.pdf之类的路径。 It worked, it showed a popover with the buttons open in iBooks and open in Dropbox, but not Send by Mail. 它工作,它显示了一个弹出窗口,按钮在iBooks中打开并在Dropbox中打开,但不是Send by Mail。 Now I've changed it with the following code: 现在我用以下代码更改了它:

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

Where pdfData is a NSData object. 其中pdfData是NSData对象。 And it works too, but now it shows the option of sending it by email, but not the iBooks option. 它也有效,但现在它显示了通过电子邮件发送它的选项,但不是iBooks选项。 I'm going nuts because I don't find the reason of that behavior and I need the two options, iBooks and Mail. 我疯了,因为我没有找到这种行为的原因,我需要两个选项,iBooks和Mail。

I don't know if it has something to do with the fact that the UIDocumentInteractionController has a path which ends with .pdf and the UIActivityViewController only has a NSData object. 我不知道它是否与UIDocumentInteractionController有一个以.pdf结尾的路径并且UIActivityViewController只有一个NSData对象这一事实有关。 But I can't find a solution for that. 但我无法找到解决方案。

Somebody has found that problem before? 有人之前发现了这个问题吗?

Thank you very much. 非常感谢你。

When you use presentOpenInMenuFromRect:inView:animated: you only get a list of apps that can work with the given file. 当您使用presentOpenInMenuFromRect:inView:animated:您只获得可以使用给定文件的应用程序列表。

What you want to use is presentOptionsMenuFromRect:inView:animated: which gives you the options that you are looking for. 你想要使用的是presentOptionsMenuFromRect:inView:animated:它为你提供了你正在寻找的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM