在iPhone上打开PDF文档 [英] Open a PDF document on iPhone

查看:113
本文介绍了在iPhone上打开PDF文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UIWebView是在iphone上打开pdf文档的唯一方法吗?我该如何与文件互动?例如:获取当前页码?

is UIWebView the only way to open a pdf document on the iphone? how can i interact with the document? eg: getting the current page number?

推荐答案

您应该阅读有关使用quartz 2d绘图的Apple文档。有一节只关于处理PDF文档。
如果您不想在UIWebView中显示PDF,则可以创建自己的视图。只是UIView的子类并覆盖自定义绘图的方法 - (void)drawRect:(CGRect)rect 。创建CGContextRef使用核心图形的特定功能直接在该上下文中绘制PDF。 Core Graphics为PDF文档提供了许多其他功能,比如Kalle已经提到的。

You should read the Apple documentation about Drawing with quartz 2d. There's a section just about handling with PDF documents. If you don't like to show a PDF in a UIWebView, you create your own view. Just subclass UIView and overwrite the method -(void)drawRect:(CGRect)rect for your custom drawing. Create a CGContextRef a draw your PDF directly in that context using the specific function of core graphics. Core Graphics provides a lot of other functions for PDF documents, like Kalle already mentioned.

如果你真的不习惯核心图形,那么有时你很难需要很多时间来适应它,所以我建议使用UIWebView来显示PDF。它相对简单。

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. It relatively simple.

这篇关于在iPhone上打开PDF文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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