dcai
dcai

Reputation: 2555

Open file in another app

My app needs to open some file types in other apps, like dropbox app does, it could list the installed apps which could open specific types of file.

How can get the app list?

Upvotes: 19

Views: 17272

Answers (3)

Nerrolken
Nerrolken

Reputation: 1995

Expanding on jtbandes's answer, here's the code that worked for me:

NSURL *url = [NSURL fileURLWithPath:filePath];
UIDocumentInteractionController *popup = [UIDocumentInteractionController interactionControllerWithURL:url];
[popup setDelegate:self];
[popup presentPreviewAnimated:YES];

And don't forget to include this in your H file:

@interface MyViewController : UIViewController <UIDocumentInteractionControllerDelegate>

Also worth noting: this will open a new fullscreen view that has a Document Viewer, as well as the Share button that offers all the various apps that can open this file. If you're just looking for the Share popup, equivalent to the UIActivityViewController, this will do it, but with some extra functionality you may not want.

Upvotes: 1

illuminatus
illuminatus

Reputation: 2086

You can use QLPreviewController from the official docs.

Upvotes: 5

jtbandes
jtbandes

Reputation: 118651

You'll want to use UIDocumentInteractionController. See also the Document Interaction Programming Guide.

Upvotes: 30

Related Questions