Three methods to preview documents on iPhone

Source: Internet
Author: User

On the iPhone, you can easily preview document files, such as pdf and word. This document takes PDF as an example. This article introduces three methods to preview PDF files, and compares them with local pdf files on the network.

Preview local PDF files:

1. Use the UIWebView Control

UIWebView is one of the most commonly used controls in iPhone development, similar to the webBrowser control in. net. Using it to preview PDF files is quite convenient and simple.

The key code for previewing a PDF file in UIWebView is as follows:

Effect:

2. Use CLPreviewController

CLPreviewController is a new feature that allows you to quickly preview a document and preview it while loading it. In other words, you do not need to load all the documents to the memory.

To preview a PDF file using CLPreviewController, You need to implement a delegate: QLPreviewControllerDataSource. The key code is as follows:

PrevoewController returns the address of the preview file.

This method is not only fast, but also provides a function to print documents on the iphone, such.

3. Drawing pdf documents

Apple has an official example of drawing pdf. This method can easily control the details of pdf presentations, but the efficiency is not high.

Preview PDF files on the network:

1. Use UIWebView to preview PDF documents on the network. First, download the documents to be previewed to the iPhone memory, and then preview the documents. For large pdf documents, the efficiency is not high, user experience is also poor.

2. For prevoewController, because it is loaded step by step, all pdf documents are not loaded at a time. The user experience is good, but a print button is added to 4.0, when you click the print button, the program goes down. It's a cup.

3. The rendering method also needs to be loaded to the memory at a time, and the rendering efficiency is not high. This method should not be used for large documents.

Solution for previewing large network documents:For pdf files on the network, for example, e-books (some e-books are relatively large), we recommend that you first download them to your local device and then preview them in the second way.

Summary:This article introduces three methods to preview pdf documents, similar to non-pdf documents. I am not familiar with iPhone development, and I am not sure what I have written. please correct me.

Code:Http://files.cnblogs.com/zhuqil/PDFView.zip

Author:Zhu Yulin

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.