1

I'm currently working on an app, that displays one pdf inside of a UIWebView. That's working fine. The pdf gets loaded like this:

NSString *path = [[NSBundle mainBundle] pathForResource:@"file_name" ofType:@"pdf"];
NSURL *url= [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];

But the pdf also contains a link on each page to return to its first page (the table of contents). I have enabled user interaction and link detection inside the .xib file. When i tested it with the simulator or on device, it worked in some cases, depending on the iOS Version.

With iOS 4.3 (only simulator): Doesn't work. Links aren't recognized and are treated like normal text. (so i guess i won't support < iOS 5)

iOS 5.1 (Simulator and Device): Works fine. Each link returns me to the first page of the pdf. No problems so far.

iOS 6.0 (Simulator and Device): The first link i use works exactly once. When i try it again, nothing happens, no matter which link i use. After a completly restart of the app, it works again, but only once.

So, does somebody know a way to get it working with iOS 6 the same way as with iOS 5.1? I have read about a few similar problems where the solutions seems to be to draw the pdf per CGDPF* api and scan the pdf for links. (something like what is collected here: Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints? ) But i would like to avoid that, if possible, because i don't need all the functions a pdf viewer could provide.

Hope there is another way and thanks for reading :)

4

1 回答 1

0

我最近遇到了这个问题。原因在于 iOS 6.1+,一旦您单击其中一个链接,您就会导航到不同的页面(第一页),并且您需要“返回”才能再次导航到文档中的任何页面。由于您正在显示与应用程序捆绑在一起的静态文档,您可能希望将这些页面链接替换为自定义链接并实现分页机制以跳转到所需的页面,例如:pdf://Page_1。如果您需要实现的只是转到第一页,那么您的分页机制可能就像将 Web 视图的滚动视图的内容偏移设置为 0 一样简单。

于 2014-08-24T07:15:12.407 回答