Yerkezhan
Yerkezhan

Reputation: 481

Open downloaded files in iOS app

How can I open downloaded files (images, pdf, word, excel, etc.) in my iOS app? Is there any way to open them using device's system tools like iBooks or this should be done in UIWebView? Example.

Upvotes: 0

Views: 1128

Answers (2)

Shoaib
Shoaib

Reputation: 1325

Try this

NSString* pdfFile = @""; //path of file here



NSURL *url = [NSURL fileURLWithPath:pdfFile];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView setScalesPageToFit:YES];
[webView loadRequest:request];

[self.view addSubview:webView];

Upvotes: 3

Akshit Zaveri
Akshit Zaveri

Reputation: 4244

You could use QLPreviewController class.

The apple documentation link is https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/QLPreviewController_Class/Reference/Reference.html

Apple Says

A QLPreviewController object, or Quick Look preview controller, provides a specialized view for previewing an item.

EDIT:

A nice tutorial about it:

http://iosdevelopertips.com/data-file-management/preview-documents-with-qlpreviewcontroller.html

Upvotes: 1

Related Questions