Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have a detailed discussion of how (and why) UIScrollView zooming works at <a href="http://github.com/andreyvit/ScrollingMadness/" rel="noreferrer">github.com/andreyvit/ScrollingMadness/</a>.</p> <p>(The link also contains a description of how to programmatically zoom UIScrollView, how to emulate Photo Library-style paging+zooming+scrolling, an example project and ZoomScrollView class that encapsulates some of the zooming magic.)</p> <p>Quote:</p> <p>UIScrollView does not have a notion of a “current zoom level”, because each subview it contains may have its own current zoom level. Note that there is no field in UIScrollView to keep the current zoom level. However we know that someone stores that zoom level, because if you pinch-zoom a subview, then reset its transform to CGAffineTransformIdentity, and then pinch again, you will notice that the previous zoom level of the subview has been restored.</p> <p>Indeed, if you look at the disassembly, it is UIView that stores its own zoom level (inside UIGestureInfo object pointed to by the _gestureInfo field). It also has a set of nice undocumented methods like <code>zoomScale</code> and <code>setZoomScale:animated:</code>. (Mind you, it also has a bunch of rotation-related methods, maybe we're getting rotation gesture support some day soon.)</p> <p>However, if we create a new UIView just for zooming and add our real zoomable view as its child, we will always start with zoom level 1.0. My implementation of programmatic zooming is based on this trick.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload