2

I'm using vfrReader and I found that drawLayer:inContext in ReaderContentPage.m called multiple times during rendering. Is it possible to catch page did rendered event?

ChikabuZ
  • 10,031
  • 5
  • 63
  • 86

1 Answers1

0

If you are willing to modify the vfrReader source, you can post an event after the CGContextDrawPDFPage call in the drawLayer:inContext: method. The CGContextDrawPDFPage function is synchronous, so the post is guaranteed to be called after the page in question has rendered.

  • The problem that drawLayer:inContext called few times and I don't know how many times it will be called. – ChikabuZ Jan 12 '16 at 08:10
  • why do you need to know when the page has been rendered? –  Jan 12 '16 at 17:25
  • I want to show "splash screen" and when page loaded show it. – ChikabuZ Jan 12 '16 at 18:16
  • If it is a single PDF page, then you can do it without using layers (and hence no background tasks). Maybe you do not need all the machinery of vfrReader in this case. Rendering a PDF page is fairly simple. You need to get the current context, and you need to transform PDF page space to your views space. Then you call CGContextDrawPDFPage. You can probably find examples online. –  Jan 12 '16 at 19:38
  • BTW you can also use a UIWebView and set its location to a PDF url. –  Jan 12 '16 at 19:39
  • It's not a single page, so in my case vfrReader is very useful. I wan't to show "splash screen" when document is opening. – ChikabuZ Jan 12 '16 at 21:43
  • Is it possible to know how many times drawLayer:inContext will be called? – ChikabuZ Jan 13 '16 at 20:03
  • @ChikabuZ - no: it will all depend on some low-level stuff about which portions of a view need to be rendered. –  Jan 13 '16 at 23:25
  • btw - if all you are doing is drawing a couple of PDF pages into a view, just do it directly. It is not that difficult to code. –  Jan 13 '16 at 23:26