简体   繁体   中英

How to use “pdfView” in object library in iOS?

I see in "object library" pdfView is there, but, when I click on .XIB it got disappers.How can I use this for iPhone or IPad development? Plaese provide me any example links.Thanks.

Note: Plaese do not tell me to use any 3rd party lib,because I'm already refering two.This i don't want ot use going forword.

PDFView is only for cocoa(OSX) not for iOS.

A PDFView object encapsulates the functionality of PDF Kit into a single widget that you can add to your application

PDFKit only available in OSX.

In iOS to display pdf pages you don't want use any third party libraries, you can draw the pdf view by creating a custom view override the draw something like

Get the pdf document

  NSString *pathToPdfDoc = [[NSBundle mainBundle] pathForResource:@"aa" ofType:@"pdf"];
  NSURL *pdfUrl = [NSURL fileURLWithPath:pathToPdfDoc];
  document = CGPDFDocumentCreateWithURL((CFURLRef)pdfUrl);
  currentPage = 1;     

In drawRect

-(void)drawRect:(CGRect)rect
{
    CGPDFPageRef page = CGPDFDocumentGetPage(document, currentPage);
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextSaveGState(ctx);
    CGContextTranslateCTM(ctx, 0.0, [self bounds].size.height);
    CGContextScaleCTM(ctx, 1.0, -1.0);
    CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, [self bounds], 0, true));
    CGContextDrawPDFPage(ctx, page);    
    CGContextRestoreGState(ctx);
}

Are you posting two questions that are pretty much the same?

A couple of minutes ago you posted this: Object library not visible when click on .XIB in xcode ios

My answer still stands, you have chosen a OSX xib NOT an iOS xib.

If you want to show a PDF in an iOS app, you could add it to a UIWebView. Have a look at this question for details: iPhone : can we open pdf file using UIWebView?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM