如何在 iOS 中创建打开方式对话框? [英] How do I create an Open With Dialog in iOS?

查看:52
本文介绍了如何在 iOS 中创建打开方式对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个创建 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,有两种方法:

presentOpenInMenuFromBarButtonItempresentOpenInMenuFromRect

使用起来相当简单,首先创建并初始化一个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 中创建打开方式对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆