Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIActivityViewController vs UIDocumentInteractionController in ios

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.

So, when do I use UIActivityViewController or UIDocumentInteractionController?

Is there any difference for Open In... & use UIActivityViewController?

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

like image 920
user2893370 Avatar asked Jan 20 '14 12:01

user2893370


2 Answers

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 documentation:

A view controller that previews, opens, or prints files whose file format cannot be handled directly by your app.

...

Use this class to present an appropriate user interface for previewing, opening, copying, or printing a specified file. For example, an email program might use this class to allow the user to preview attachments and open them in other apps.

After presenting its user interface, a document interaction controller handles all interactions needed to support file preview and menu display. You can also use the delegate to participate in 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.

UIActivityViewController documentation:

A view controller that you use to offer standard services from your app.

...

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.

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.

like image 128
sangony Avatar answered Nov 15 '22 19:11

sangony


Basically UIActivityViewController shares Data Objects (like Strings or Images) where UIDocumentInteractionController shares whole Documents / Files f.e. a PDF.

like image 40
Mario Avatar answered Nov 15 '22 21:11

Mario