IOS loading files in PDF format

Source: Internet
Author: User

Can be loaded in a way more, for the time being summed up two kinds:

Locally piloted into a PDF file

Type 1: Load with UIWebView

UIWebView *webview = [[UIWebView alloc] Initwithframe:cgrectmake (00, Self.view.bounds.size.width, Self.view.bounds.size.height)];    [Self.view Addsubview:webview];     *path = [[NSBundle mainbundle] Pathforresource:@ " based on Apache+jmeter" ofType:@ "  PDF"];     *url = [Nsurl Fileurlwithpath:path];     *request = [Nsurlrequest requestwithurl:url];    [WebView loadrequest:request];

Type 2: Frame Quicklook with preview file of the system

First import the frame quicklook.framework

Introducing Header Files #import <QuickLook/QuickLook.h>

Instantiating an Object

  Qlpreviewcontroller *myqlpreviewcontroller = [[Qlpreviewcontroller alloc]init];    Myqlpreviewcontroller. delegate = self;     = self;    [Myqlpreviewcontroller Setcurrentpreviewitemindex: 0 ];     // Here you can go with the navigation bar, or you can jump without the navigation bar, you can also get the view to add    [Self Presentviewcontroller:myqlpreviewcontroller animated:yes completion:^{        NSLog (@ " Jump Completion " );    }];

Declaring an agent

<QLPreviewControllerDelegate,QLPreviewControllerDataSource>

Implementation protocol

#pragma mark-qlpreviewcontroller agent-(Nsinteger) Numberofpreviewitemsinpreviewcontroller: (Qlpreviewcontroller *) controller{    return 1;} -(id<qlpreviewitem>) Previewcontroller: (Qlpreviewcontroller *) controller previewitematindex: (NSInteger) index{        NSString *path = [[NSBundle Mainbundle] pathforresource:@ "based on Apache+jmeter" oftype:@ "PDF"];    return [Nsurl Fileurlwithpath:path];} -(void) Previewcontrollerdiddismiss: (Qlpreviewcontroller *) controller{    NSLog (@ "Preview interface has disappeared");} File internal link Click No external jump-(BOOL) Previewcontroller: (Qlpreviewcontroller *) controller shouldopenurl: (nsurl *) URL Forpreviewitem: (id <QLPreviewItem>) item{    return NO;}

At this end, the loading process may be slow, after all, a local PDF file needs to be loaded;

Two ways to compare can be seen, the first kind of loading is more convenient, but the memory consumption of more, the second memory consumption of less, I actually measured the difference of 20MB (with the simulator).

Mark---------

IOS loading files in PDF format

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.