View the PDF file for IOS download (with download progress)

Source: Internet
Author: User

In IOS (object-c), it is quite easy to download and view PDF files. Before downloading, you must first pass the directory of the IOS file that can be saved again:

 

IOS file storage directory

IOS can customize the file directories to be written, which is very limited. Only these three directories can be used:

1. NSDocumentDirectory

Download the file to this directory. You can use iTunes to view the file directly. For files that are not secure and easy to browse, you can download them to this directory as pdf. ,

2. NSLibraryDirectory

If the file is downloaded to this directory, the file cannot be directly viewed using iTunes. You can only view the file in the APP. You can download the file to this directory for security considerations.

3. NSCachesDirectory

This directory stores cached files, such as cached image data. It is not suitable for storing permanent files.

 

This article prohibits reprinting on any website and severely condemn the worms.
This article was first published in, blog garden. Please search: blog garden-Find yourself and view the original article
This article first address: IOS download view PDF file (with download progress)-http://www.cnblogs.com/xunziji/p/3242843.html

Download pdf files for IOS

In the IOS development process has been used AFNetworking (https://github.com/AFNetworking/AFNetworking) responsible for network communication, and this open-source component is very stable, easy to use, at the same time also a lot of people, various online solutions are available. This component is also used for this download.

* paths =* _filePath = [paths objectAtIndex:NSString* fileUrl = fileUrl = [fileUrl stringByReplacingOccurrencesOfString:  withString:NSURLRequest* request =* fileName = * filePath =AFURLConnectionOperation *operation ==^(NSUInteger bytesRead,   totalBytesRead,       progress =   ()totalBytesRead /     (progress == [operation setCompletionBlock:^

 

This article prohibits reprinting on any website and severely condemn the worms.
This article was first published in, blog garden. Please search: blog garden-Find yourself and view the original article
This article first address: IOS download view PDF file (with download progress)-http://www.cnblogs.com/xunziji/p/3242843.html

View PDF files

There are many ways to view PDF files in IOS, but WebView is the easiest and most convenient, although not the most powerful.

 

NSArray* paths =* filePath = [paths objectAtIndex:* fileName = *path ===* url =*request =

 

This article prohibits reprinting on any website and severely condemn the worms.
This article was first published in, blog garden. Please search: blog garden-Find yourself and view the original article
This article first address: IOS download view PDF file (with download progress)-http://www.cnblogs.com/xunziji/p/3242843.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.