UIActivityViewController与ios中的UIDocumentInteractionController [英] UIActivityViewController vs UIDocumentInteractionController in ios

查看:216
本文介绍了UIActivityViewController与ios中的UIDocumentInteractionController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在iOS上阅读了关于 UIActivityViewController UIDocumentInteractionController 的一些文章,但我对如何使用感到非常困惑因为两者看起来都一样。

I just read some articles on UIActivityViewController and UIDocumentInteractionController in iOS, but I am very confused about how to use them because both seem the same.

所以,我何时使用 UIActivityViewController UIDocumentInteractionController

So, when do I use UIActivityViewController or UIDocumentInteractionController?

是否有任何差异... &使用 UIActivityViewController

我对如何使用它们感到非常困惑。请告诉我他们的具体用法。

I am very confused about how to use them. Please clarify to me their specific use.

推荐答案

简而言之, UIDocumentInteractionController UIActivityViewController 处理应用中的各种其他服务时处理文件。我不是一个批评太多的人,但你至少应该尝试谷歌并至少阅读iOS开发者文档中的概述。

In short, UIDocumentInteractionController deals with files while UIActivityViewController deals with various other services in your app. I'm not one to criticize much but you really should at least try to google and read at least the overview in the iOS Developer Docs.

UIDocumentInteractionController概述:

文档交互控制器与委托对象一起提供应用程序内支持,以管理用户与本地系统中文件的交互。例如,电子邮件程序可能使用此类允许用户预览附件并在其他应用程序中打开它们。使用此类来显示用于预览,打开,复制或打印指定文件的适当用户界面。

A document interaction controller, along with a delegate object, provides in-app support for managing user interactions with files in the local system. For example, an email program might use this class to allow the user to preview attachments and open them in other apps. Use this class to present an appropriate user interface for previewing, opening, copying, or printing a specified file.

在呈现其用户界面后,文档交互控制器处理所有交互需要支持文件预览和菜单显示。在某些情况下,对象使用委托来确定如何响应特定命令。例如,要提供复制或打印,您必须实现 documentInteractionController:canPerformAction: documentInteractionController:performAction:委托方法。

After presenting its user interface, a document interaction controller handles all interactions needed to support file preview and menu display. In some cases the object employs a delegate to determine how to respond to specific commands. For example, to provide copying or printing, you must implement the documentInteractionController:canPerformAction: and documentInteractionController:performAction: delegate methods.

您还可以使用代理参与所呈现界面中发生的交互。例如,当文件即将被移交给另一个应用程序以进行打开时,会通知代理。有关可在代理中实现的方法的完整说明,请参阅 UIDocumentInteractionControllerDelegate 协议参考

You can also use the delegate to participate with interactions occurring within the presented interface. For example, the delegate is notified when a file is about to be handed off to another application for opening. For a complete description of the methods you can implement in your delegate, see UIDocumentInteractionControllerDelegate Protocol Reference.

UIActivityViewController概述:

UIActivityViewController 类是一个标准视图控制器,可用于从应用程序提供各种服务。该系统提供多种标准服务,例如将项目复制到粘贴板,将内容发布到社交媒体网站,通过电子邮件或SMS发送项目等。应用程序还可以定义自定义服务。

The UIActivityViewController class is a standard view controller that you can use to offer various services from your application. The system provides several standard services, such as copying items to the pasteboard, posting content to social media sites, sending items via email or SMS, and more. Apps can also define custom services.

您的应用程序负责配置,显示和关闭此视图控制器。视图控制器的配置涉及指定视图控制器应该在其上操作的数据对象。 (您还可以指定应用程序支持的自定义服务列表。)在呈现视图控制器时,必须使用适用于当前设备的方法。在iPad上,您必须在弹出窗口中显示视图控制器。在iPhone和iPod touch上,您必须以模态方式呈现它。

Your app is responsible for configuring, presenting, and dismissing this view controller. Configuration for the view controller involves specifying the data objects on which the view controller should act. (You can also specify the list of custom services your app supports.) When presenting the view controller, you must do so using the appropriate means for the current device. On iPad, you must present the view controller in a popover. On iPhone and iPod touch, you must present it modally.

这篇关于UIActivityViewController与ios中的UIDocumentInteractionController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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