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 :)

Community
  • 1
  • 1

1 Answers1

0

I recently ran into this problem. The reason is with iOS 6.1+, once you click on one of those links, you navigate to a different page (first page) and you need to "goBack" before you are able to navigate again to any page in the document. Since you're displaying static documents that are bundled with the app, you may want to replace these page links with custom links and implement a paging mechanism to jump to the desired page like: pdf://Page_1. If all you need to implement is go to first page, your paging mechanism could be as simple as setting the content offset of the web view's scroll view to 0.

Ahmed Hamed
  • 504
  • 1
  • 3
  • 11