我有一个创建 jpg 图像的应用程序.现在我想打开一个对话框,显示可以打开 jpg 图像的所有可能的应用程序.当我点击对话框中的应用程序之一时,应该打开被点击的应用程序并获取 jpg 图像作为参数.
I have a app that creates jpg images. Now I want to open a dialog which shows all the possible apps which can open a jpg image. When I tap on one of the apps in the dialog the tapped app should be opened and get the jpg image as parameter.
这是来自另一个应用程序的这样一个对话框:
Here such a dialog from another app:
上面的对话框显示了我可以用来打开我的 jpg 图像的所有应用程序.
The dialog above shows all the apps where I can open my jpg image with.
如何在 iOS 中创建和使用这样的对话框?
推荐答案在 UIDocumentInteractionController,有两种方法:
presentOpenInMenuFromBarButtonItem 和 presentOpenInMenuFromRect
使用起来相当简单,首先创建并初始化一个UIDocumentInteractionController的实例:
Quite simple to use, first create and initialize an instance of UIDocumentInteractionController:
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:yourFilePathURL];接下来使用上述方法之一显示打开对话框.
Next present the open-in dialog using either one of the above mentioned methods.
更多推荐
如何在 iOS 中创建打开方式对话框?
发布评论