- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望有人能帮助解决我在使用 UIDocumentInteractionController 时遇到的一个非常令人沮丧的问题。
我需要调用“presentOpenInMenuFromRect”方法,以允许用户在另一个应用程序中打开文件。在这个阶段,我只是在做概念验证,所以我只是使用非常基本的文件类型来进行测试。
我已经使用下面的代码设置了我的 UiDocumentInteractionController,并验证了文件路径 URL 是正确的,因为我可以成功调用 presentPreviewAnimated 方法,并且文档确实可以在预览模式下正常打开。
我遇到的问题是“presentOpenInMenuFromRect”总是返回 NO,无论我使用什么文件类型。到目前为止,我使用了以下常见的文件类型,均无济于事:jpg、png、pdf、txt、rtf 和 html。
如果有人遇到这个问题,我将不胜感激。当然,这些文件中至少有一个应该被设备识别为具有关联的应用程序(并且它预览 OK 的事实实际上不能证明这一点吗?)我想知道我在做一些更根本性的错误吗?顺便说一句,我正在 iPhone 上调试,所以这不是模拟器的怪癖。
非常非常欢迎任何建议!提前致谢。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSURL *filePath = [NSURL fileURLWithPath:[documentsDirectory stringByAppendingPathComponent:@"test.txt"]];
documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:filePath];
documentInteractionController.delegate = self;
[documentInteractionController retain];
// The following line does work, so we know the UIDocumentInteractionController and filepath are fundamentally correct
// [documentInteractionController presentPreviewAnimated:YES];
// Method ALWAYS returns NO, no matter what file type is used
if (![documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES])
NSLog(@"Failed to show Open In menu");
最佳答案
只是想我会为遇到同样问题的其他人发布更新...我现在相信“打开方式”菜单没有出现的原因很简单,因为没有安装任何应用程序我使用的文件扩展名。
这现在看起来相当明显,但当时我假设一些更常见的文件类型将与系统应用程序等相关联 - 但是在安装 Adobe Reader 后,这现在似乎适用于 pdf。
关于ios/Objective C - UIDocumentInteractionController - 'Open In' 方法总是返回 NO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14475313/
是否可以检查设备上有多少个能够处理特定文件类型的应用程序?基本上,我的应用程序中有一个按钮,允许用户在另一个应用程序中打开,但如果没有可能的应用程序可以打开文档,我不想显示它。 最佳答案 好吧,所以想
我不知道这段代码有什么问题,但每次运行应用程序时,显示菜单后,应用程序都会崩溃。 NSString * path = [[NSBundle mainBundle] pathForResource:@"
我在容器 View 中有一个 UIViewController。 View Controller 在 UIDocumentInteractionController 中显示 PDF,如下所示: let
我有一个 PDF 显示在 UIDocumentInteractionController它很棒。 问题是,该应用程序的重点是保护 PDF 不被共享等。因此我想摆脱出现的选项按钮。 堆栈上有 1000
我一直在使用 Apple 示例代码从这里查看文档: https://developer.apple.com/library/ios/samplecode/DocInteraction/Listings
我有从 UIAlertController 中调用的代码: func createSomeFile() { var output = (some NSData to output to fil
如何指定可用于 UIDocumentInteractionController 的“打开方式”功能的特定“白”应用程序列表?我在 UIDocumentInteractionController 文档中
我的应用程序中的一个屏幕显示了本地镜像的预览,我在左上角有一个操作按钮,我用它来显示文档交互选项: - (IBAction)actionButtonTapped:(id)sender { se
我有一个 ics(日历)文件,我使用 presentOptionsMenuFromRect: 使用 UIDocumentInteractionController 打开它。运行时,“打开方式”菜单看起
我的 IOS 应用程序的方向已锁定为纵向模式。但是,我想支持使用 UIDocumentInteractionController 打开的文件的横向和纵向。这是我打开文件 url 的代码。 let u
我使用 UIDocumentInteractionController 在我的应用程序中预览文档。但是,有时文档显示良好,有时交互 Controller 显示消息“读取文档时出错”。我知道这不是文档的
我对 UIDocumentInteractionController 非常绝望。我唯一想做的就是与注册 PDF 的所有其他应用程序共享我的应用程序中的 pdf 文件。 这是我的代码: NSString
这里有一个奇怪的 iOS 问题... 我有一个可以在我的 iPad 上打开 PDF 的应用程序。 (我只需要在我所处的环境中处理 iPad) 奇怪的是,有时当我尝试加载文件时(DocumentInte
我使用- (BOOL)presentPreviewAnimated:(BOOL)animated; 来加载文档,然后我想从文档中截取屏幕截图。所以我尝试 UIGraphicsBeginImageCon
在我的应用程序中,我下载各种格式的文件。我试图让 UIDocumentInteractionController 获得可以打开这种格式的应用程序。问题是 UIDocumentInteractionCo
我想在应用程序中分享保存的 PDF。实际上,它不适用于 PRINT,也不适用于 MAIL,它正在通过 Whatsapp 和其他应用程序进行共享。 { let fileManager = Fil
在我的 iOS 应用程序中,我使用 DocumentInteractionController 来预览 .csv 文档。 self.documentController = [UIDocume
在我的应用程序中,我想下载各种类型的文件并导出,以便用户可以使用打开此类文件的应用程序打开文件。我正在尝试使用 UIDocumentInteractionController 但在下载后将其保存到我的
我正在使用 UIDocumentInteractionController 与其他应用程序共享在我的应用程序中拍摄的图像。当您使用它与 Instagram 分享时,您可以使用包含键 @"Instagr
当用户从 tableView 中选择一个文件时,我试图从导航 Controller 中呈现一个 UIDocumentInteractionController。 interactionControll
我是一名优秀的程序员,十分优秀!