如何在 iOS 中创建打开方式对话框?

编程入门 行业动态 更新时间:2024-10-09 11:27:25
本文介绍了如何在 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,有两种方法:

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 中创建打开方式对话框?

本文发布于:2023-11-13 06:16:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583670.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   方式   如何在   iOS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!