Question

I need your help with UIActivityViewController. I need to present activity controller for the file where, except for default actions, the user will be able to open the file in other apps. I know how to do this with UIDocumentController, which shows popover with all apps able to open the file. But how can I show all these apps in UIActivityViewController?

P.S. This behavior can be seen in Apple Mail app, for example.

Was it helpful?

Solution

Look at TTOpenInAppActivity for a way to combine both a UIActivityViewController (for normal sharing), and an 'Open in' button on that which brings up a UIDocumentInteractionController. Pre-iOS 8, that is the best way to manage this.

OTHER TIPS

The function and behavior is different between UIActivityViewController and UIDocumentController.

UIActivityViewController
Presents activities that are pre-defined, you can pass an array to select which ones should be excluded among the default ones that are presented, if you want to add more activities you have to use custom activities, unfortunately these will appear bellow the rest of the activities and even more, the icon will always be gray, your app never loses control since you can use delegates and other stuff to know what is going on on those apps. (Unless you manually make an activity which opens another app)

UIDocumentController
This one asks the system for all the registered applications for a certain file extension, many apps have registered their exclusive extensions which makes it so that this app will be the only one displayed. If you pass an image, you will see all the apps that can handle this file. When using this one your app will lose control since the other app will be opened.

What is your final objective?, If you describe it with more detail we could offer you a better solution.

From what i understand, you should see yourself what type of file the user is trying to open, and then yourself open it with the most suitable one. Since you cant really emulate what apple is doing, you should handle this problem through your interface, offer the user to "share" or to "open with" for example.

The answer is very simple. There is no way to do it. You cannot add the apps except the defaults into the UIActivityViewControllers.

You are absolutley correct, you can acheive this through the UIDocumentInteractionController.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top