Here is the code:
https://www.dropbox.com/s/o42wy36x4qhrbpt/PDFScroller.zip
I took the WWDC 2010 PhotoScroller
sample code that implements nested UIScrollViews
for zooming, inside a UIScrollView
for paging, and swapped out what I thought would be minimal amount of code required for displaying a multi-page PDF instead of images.
It works. But it's slow on my iPhone4, about three seconds to paint the first page, and even slower on my iPod Touch. I can watch it painting the individual tiles. This same PDF already opens up more quickly, with no visible tile drawing, in an alternate CATiledLayer
implementation I have which simply uses a single CATiledLayer
/UIScrollView
and touch events to change pages. I'd like to use this PhotoScroller
technique, it's very nice.
I watched it with CPU Sampler in Instruments, and it doesn't seem to be the PDF rendering code, it looks like the time is taken up in threading and messaging. I'd appreciate it if someone could help point out what this sample is doing to incur the overhead.
Thanks,
Jim
Update 1: I had originally used the TilingView
class technique from the sample code of defining
+ (Class) layerClass {
return [CATiledLayer class];
}
And then drawing in - (void)drawRect:(CGRect)rect
but switched to the explicit CATiledLayer
subclass as a first attempt at seeing whether it would make a difference, but it did not, and so I left the code as-is for posting here. There is also a missing [tiledLayer release];
leak in TilingView.
See this Thread Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints? for PDF rendering tips.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With