CruorVult
CruorVult

Reputation: 823

UIDocumentInteractionController: open file whith native application

The documentation says that UIDocumentInteractionController allows to open file implicitly (UTI property is nil) with installed apps but not native.

UIDocumentInteractionController *controller = [UIDocumentInteractionController  interactionControllerWithURL:fileURL];
[controller retain];
controller.delegate = self;
//controller.UTI = uti;

CDVViewController* cont = (CDVViewController*)[ super viewController ];
CGRect rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height);
[controller presentOpenInMenuFromRect:rect inView:cont.view animated:YES];

Is it possible to open for example pdf file in Safari or image in gallery?

P.S. I am new in Objective C :)

Upvotes: 3

Views: 3936

Answers (2)

B.S.
B.S.

Reputation: 21726

It is not possible to say the device what application must open your file.

You can use UIApplication's OpenUrl method to phone for example, or to launch Safari with some url.. For example:

[[UIApplication sharedApplication] openURL:@"tel://%i", someNumber];

But if you want to open a specific file you must use UIDocumentInteractionController.

Also there is QLPreviewController API to preview documents. Here is tutorial how to use it and to see how it looks.

Upvotes: 3

CruorVult
CruorVult

Reputation: 823

I've used presentPreviewAnimated to preview the file with UIDocumentInteractionController instead of presentOpenInMenuFromRect.

Upvotes: 1

Related Questions