如何使用“pdfView”在iOS中的对象库中? [英] How to use "pdfView" in object library in iOS?

查看:297
本文介绍了如何使用“pdfView”在iOS中的对象库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在对象库 pdfView 中看到了,但是,当我点击.XIB时,它有了disappers。我如何将它用于iPhone或iPad开发? Plaese为我提供了任何示例链接。谢谢。

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.

注意:Plaese并没有告诉我使用任何第三方库,因为我已经引用了两个。这个我不想使用前进。

推荐答案

PDFView仅适用于cocoa(OSX)而不适用于iOS 。

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


PDFView对象将PDF Kit的功能封装到您可以添加到应用程序的单个小部件中

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

仅在OSX中可用的PDFKit。

PDFKit only available in OSX.

在iOS中显示pdf页面你不想使用任何第三派对图书馆,您可以通过创建自定义视图来绘制pdf视图,覆盖类似的绘图

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

获取pdf文档

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

在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);
}

这篇关于如何使用“pdfView”在iOS中的对象库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆