[英]iPhone - “Open In” in SDK?
The DropBox app lets you view a document in another app by selecting the Open In
option. DropBox应用程序允许您通过选择“
Open In
选项查看其他应用程序中的文档。
We are building a document management app and need to be able to view the Word/Excel docs like Dropbox does, in another app. 我们正在构建一个文档管理应用程序,并且需要能够在另一个应用程序中查看Dropbox的Word / Excel文档。
Where in the SDK do I look so that I can pass a document to another app to open in that one? 我在SDK中的哪个位置,以便我可以将文档传递给另一个应用程序以在该应用程序中打开?
Ian 伊恩
You'll need to use the UIDocumentInteractionController
class. 您需要使用
UIDocumentInteractionController
类。
It's available in UIKit, so you don't need a particular framework for this. 它在UIKit中可用,因此您不需要特定的框架。
You instantiate this class, using an URL to the file you want to pass to another application, which is able to handle the file type: 您使用要传递给另一个应用程序的文件的URL来实例化此类,该应用程序能够处理文件类型:
UIDocumentInteractionController * controller;
controller = [ UIDocumentInteractionController interactionControllerWithURL: someFileURL ];
Then, you can present it: 然后,你可以呈现它:
[ controller presentOpenInMenuFromRect: someRect inView: someView animated: YES ];
Note that, on iPad, you'll need to retain the controller, otherwise it will be deallocated, making your application crash. 请注意,在iPad上,您需要保留控制器,否则它将被取消分配,从而导致应用程序崩溃。
This method returns a BOOL
value. 此方法返回
BOOL
值。 NO
is returned if no application for the file type was found. 如果未找到文件类型的应用程序,则返回
NO
。 In such a case, you may display an alert. 在这种情况下,您可以显示警报。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.