UIActivityViewController vs UIDocumentInteractionController in ios - 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.

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.

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

Related

Files App View Controller?

In Pages, Numbers, and Keynote 3.3 for iOS, Apple has done away with its custom file manager and instead uses the a version of the iOS 11 Files App to allow the user to choose and save files within the applications,
The Files-like document picker User Interface on Pages and Keynote 3.3 for iOS 11:
Is this a publicly available view controller that developers can implement in 3rd-Party Applications?
Apple mentions in a user support document that these apps "work together" to present this view. Link: https://support.apple.com/en-us/HT208077
It is UIDocumentBrowserViewController.
As far as "how did they make it the root view controller of the app? Isn't [it] usually presented from another View Controller?"
Check this page: Adding a Document Browser to Your App.
Always assign the document browser as your app's root view controller.
Don't place the document browser in a navigation controller, tab bar,
or split view, and don't present the document browser modally.
There are a lot of useful resources on that page, but a lot seems to hinge on your app being "Document Based" (About Document-Based Applications in iOS).

Is there a standard iOS UI control which implements open-in like UI?

I want to build open-in like UI (see picture below).
It should include a list of icons representing actions and cancel button. I want pretty much UIAlertController only with icons (vs plain text).
Is there a standard iOS control which does something like or that or will I have to build/find a custom UI control for that?
From Apple's docs, each displayed service/action is a UIActivity, which is an abstract class, displayed in a UIActivityViewController which you can customize. There are several built-in services, and you can create your own w/custom icons. Yes, UIActionSheet was deprecated in iOS8.
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.
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.
Also see this related question on some image gotchas ...
And this tutorial on adding a custom UIActivity to the view.

Show Powerpoint Presentation in iOS

In my app I have dropbox implementation and user can download the documents from dropbox and see that one by one like a slideshow. My Problem is that if user downloads .ppt file then how to show powerpoint presentation with all its animations on iPhone without using other app like slide shark.
Only way is Using the Quick Look Framework.
Use the Quick Look framework to provide previews of items that are in formats you don’t handle—such as iWork or Microsoft Office. This framework affords you more control over the preview process than you get from the UIDocumentInteractionController class—including choosing whether the preview is displayed in the context of a navigation controller or modally (full screen). The primary class in this framework is QLPreviewController, which provides a specialized view for previewing an item. It relies on a delegate for mediating preview actions, and a data source for providing the preview items.
In iOS 4.2 and later, the specialized view presented by a Quick Look preview controller includes an action button with a Print item. If the controller can provide a preview of a file, it can also print it. There is no printing code for you to write.
To display a Quick Look preview controller you can use any of these options:
Push it into view using a UINavigationController object.
Present it modally, full screen, using the
presentModalViewController:animated: method of its parent class,
UIViewController.
Present a document interaction controller (as described in
“Previewing and Opening Files.” The user can then invoke a Quick
Look preview controller by choosing Quick Look from the document
interaction controller’s options menu.
A Quick Look preview controller can display previews for the following items:
Microsoft Office documents (Office ‘97 and newer)
iWork documents
Rich Text Format (RTF) documents
PDF files
Images
Text files whose uniform type identifier (UTI) conforms to the
public.text type (see Uniform Type Identifiers Reference)
Comma-separated value (csv) files
look at UIDocumentationInteractionController, which may be easier than using Quick Look, depending on your needs, you can control animation better then Quick look but need lots of digging.

UIActionSheet-like control similar to iOS 7 Safari's

I'm trying to create a UIActionSheet similar to Safari's. I haven't been able to find anything in the Apple documentation on how to make a UIActionSheet look like this. Is there a control/API that I am missing that I can use to create what's below, or am I stuck with creating my own UIView and displaying that?
Ninja Edit: This appears to be a UIActivityViewController. Is there any way I can add my own custom actions to it?
That is not a UIActionSheet.
It is a UIActivityViewController:
https://developer.apple.com/library/ios/documentation/uikit/reference/UIActivityViewController_Class/Reference/Reference.html
From Apple's Documentation:
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.
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.
About the ninja edit : Yes you can add actions to the UIActivityViewController.
See UIActivity on Apple's doc, or this SO question.

(iOS 6) Using a custom subclass of UIActivity from outside of a UIActivityViewController

I have added sharing to my app by way of iOS 6's UIActivityViewController. In addition to the usual suspects (Twitter, Facebook, etc.) I am also using a subclass of UIActivity I created to enable sharing to another service (App.net). Everything is working fine.
Now I would like to add an option whereby the user can choose a default sharing service, so that when he taps my app's Share button, rather than the UIActivityViewController coming up, instead the interface for the user's chosen default service comes up. Now, I can do this for the standard system services (Facebook and Twitter) using a SLComposeViewController. However I don't see any way of using SLComposeViewController to bring up my custom UIActivity's user interface.
Is there any way I can call my custom UIActivity subclass and bring up its UI directly (i.e. NOT from within a UIActivityViewController)?
I don't see why you would want to be doing this. Since you obviously have some method of creating your own sharing view controller, you could just use this again - no need to go the UIActivity-route (which is a terrible API by the way).

Resources