Search code examples
iphoneuiscrollviewcatiledlayer

How to determine the correct UIScrollView zoomScale with a CATiledLayer


I created a UIScrollView with a CATiledLayer for a 10000x8078 image.

Would I place this image in a UIView the zoomScale is always updated according to the contentSize (respectively the size of the image).

With CATiledLayer the contentSize now varies according to the tiles in use.

How can I now determine the correct zoomScale of the UISrcollView?

Thanks


Solution

  • What has worked for me, based on the the ZoomingPDFViewer Sample Code, is to keep tabs on the zoom manually the following way in the UIScrollView delegate:

    - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
    {
    
        scrollView.scrollEnabled = YES;
        // set the new scale factor for the TiledPDFView
        pdfScale *=scale;
            ....