[英]Open a PDF document on iPhone
is UIWebView the only way to open a pdf document on the iphone? UIWebView是在iPhone上打开pdf文档的唯一方法吗? how can i interact with the document? 我如何与文件互动? eg: getting the current page number? 例如:获取当前页码?
You should read the Apple documentation about Drawing with quartz 2d. 您应该阅读有关使用石英2d绘图的Apple文档。 There's a section just about handling with PDF documents. 有一节专门介绍如何处理PDF文档。 If you don't like to show a PDF in a UIWebView, you create your own view. 如果您不希望在UIWebView中显示PDF,则可以创建自己的视图。 Just subclass UIView and overwrite the method -(void)drawRect:(CGRect)rect
for your custom drawing. 只需将UIView子类化并覆盖自定义绘图的方法-(void)drawRect:(CGRect)rect
。 Create a CGContextRef a draw your PDF directly in that context using the specific function of core graphics. 创建CGContextRef,使用核心图形的特定功能直接在该上下文中绘制PDF。 Core Graphics provides a lot of other functions for PDF documents, like Kalle already mentioned. Core Graphics为PDF文档提供了许多其他功能,例如已经提到的Kalle。
If you're not really used to core graphics, it's really difficult sometimes and you probably need a lot time to get used to it, so I recommend using UIWebView to display a PDF. 如果您真的不习惯图形核心,有时确实很困难,并且可能需要很多时间来适应它,所以我建议使用UIWebView来显示PDF。 It relatively simple. 它相对简单。
Beside UIWebView, if you want a high level interaction class, check out: UIDocumentInteractionController , QLPreviewController . 在UIWebView旁边,如果您需要高级交互类,请签出: UIDocumentInteractionController , QLPreviewController 。
Depending on your needs, check out the accepted answer to this question. 根据您的需要,查看此问题的可接受答案 。
It's not the only way. 这不是唯一的方法。 There's a whole toolkit built in which lets you render PDF pages to a UIView. 有一个内置的完整工具包,可让您将PDF页面呈现到UIView。 Check out: 查看:
to name a few (core graphics) functions that relate to PDF rendering. 仅列举一些与PDF渲染相关的功能(核心图形)。
查看Apple的ZoomingPDFViewer中的简单示例: http : //developer.apple.com/library/ios/#samplecode/ZoomingPDFViewer/Introduction/Intro.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.