I have done it. The code was closed to the payment client, so I canβt share it directly, but the main idea is to write:
One subclass of UIView that displays a single PDF page using the CGPDFPageRef and CGPDFDocument* and CGContextDrawPDFPage families of functions. This helps a lot for this view to return the [CATiledLayer class] from the layerClass class layerClass and set the layerOfDetail and tileSize levels correctly. Mine also implements sizeThatFits to return the page size plus a small gutter, and displays a thin dropshadow around the edge of the pdf page.
Remember that the UIKit drawing is in reverse order from the CG drawing; therefore, before drawing, do CGContextTranslateCTM(ctx, 0.0, layer.bounds.size.height); CGContextScaleCTM(ctx, 1.0, -1.0); CGContextTranslateCTM(ctx, 0.0, layer.bounds.size.height); CGContextScaleCTM(ctx, 1.0, -1.0); .
One subclass of UIView containing and installing (and being a delegate to) UIScrollView in swap mode (main horizontal pager) and an individual UIScrollView for each page, each of which contains one of the above views (to scale separate pages.) Nested scroll views are explicit Apple-approved way of doing things like this. This opinion will have to lay out the pages as you want them; presumably in one long horizontal strip, each scaled to a suitable size.
If you do not need to scale the pages, you can skip the nested scroll views and lay out the page views right in the horizontal scroller.
TL DR: Unfortunately, this is not as simple as dropping it into a UIWebView; but it is doable, and a simple approach really works.
source share