12.5 C
New York
Sunday, November 29, 2020
Home How to How to Previewing documents on Iphone

How to Previewing documents on Iphone


Just like on the Macintosh, the iPhone SDK contains a technology known as Quick Look for previewing documents. By using a CLP review Controller object, you can easily view multiple documents of several formats, including Microsoft Office, Apple work, PDF, rich text, images, and more. Next you’ll see how, with just a couple of lines of code, you can create a simple PDF viewer, complete with paging and touch enabled resizing. This example can, of course, be extended to work with any of the document types supported by Quick Look. In this example, you’ll view the iPhone Users Guide, which can be downloaded from Apple at http://manuals.info.apple. com/en/iphone_user_guide.pdf.

To create a PDF viewer:
1. Create a new view-based application, saving it as Quick Look Example.
2. Drag the iPhone Users Guide PDF into the Resources section in the Groups & Files pane. Make sure that the “copy items into destination group’s folder (if needed)” check box is selected F.
3. In the Groups & Files pane, expand the Targets section, right-click your application target, and select Get Info.
4. Making sure the General tab is selected, click Add (+) at the bottom of the Linked Libraries list, and add the
Quick Look framework G.
5. Open Quick Look Example View Controller .h, include the Quick Look.h header, add the protocol QLP review Controller Data Source, and create an instance variable to hold your Quick Look view controller (Code Listing 6.4).
6. Next, switch to Quick Look Example View Controller .m, uncomment the view Did Load method, and add the following code: live Controller = [[QLP review Controller allot] init]; ql View Controller. Data Source = self; [self create]; Here you are simply creating a Quick Look preview controller and setting its data source. You also call the create method, which adds the button that will be used to show the Quick Look preview controller.
7. Next, create the show Preview method: [self present Modal View Controller: ql View Controller animated: YES]; which simply shows the Quick Look preview controller on the screen.

8. Now you need to implement the two QLP review Controller Data Source data source methods so that the Quick Look preview controller knows what to display. First you implement the number Of Preview Items in Preview Controller: method. In this example, since we have only a single PDF file,
You simply return the number 1. Return 1; you then implement the preview Controller: preview Item at Index:
Method: Nesting *document Location = [[Unbundle main Bundle] path For Resource:@”iphone_user_guide” ofType:@”pdf”];NSURL *myQL Document = [NSURL file URL with Path: document Location]; return myQLDocument; Here you retrieve the path of your PDF and use it to create and return an NSURL object.
Code Listing 6.5 shows the completed code.

9. Build and run the application tapping the Show Preview button causes the Quick Look preview controller
to load . You can navigate through the pages of the PDF by flicking your finger up and down on the screen. Note how your current page is displayed in the top-right corner and the document name is displayed in the title bar H. By pinching or double-tapping the screen, you should be able to zoom in to read the document in greater detail. For more information on Quick Look, refer to the Quick Look Framework Reference in the developer documentation.


Sussan Deyhim is from Electrician Durham and a University Lecturer. She loves to write on technical topics like Electrician Chapel Hill. She is writing from last three years


The best Black Friday Chromebook deal you can still shop today

Black Friday is over, but there are still some great deals like this Lenovo Chromebook 3 deal from Walmart.

Shop the best tech gifts from Western Digital: Accessories for gamers and more

Looking for some storage upgrade? Western Digital has a great selection of products for the holidays.

This fantastic Lenovo laptop is still down $250 in price following Black Friday

Black Friday is over, but Staples is still selling the Intel version of the Lenovo IdeaPad Slim 7 at a $250 discount that takes the laptop's price down to $630.

This 21-inch HP monitor is still $85 at Amazon following Black Friday

The HP Pavilion 22cwa, a 21.5-inch Full HD monitor, is still on sale on Amazon with a $15 discount that takes its price down to $85, even after Black Friday.