I have a detailed discussion of how (and why) scaling UIScrollView works on github.com/andreyvit/ScrollingMadness/ .
(The link also contains a description of how to programmatically scale UIScrollView, how to emulate paging in the style of a photo library + zoom + scroll, an example project and the ZoomScrollView class that encapsulates some zoom magic.)
Quote:
UIScrollView does not have the concept of “current zoom level” because each of its subviews can have its own current zoom level. Note that there is no field in UIScrollView to maintain the current zoom level. However, we know that someone preserves this zoom level because if you increase the zoom of the preview, then reset it to CGAffineTransformIdentity and then hold it again, you will notice that the previous subview zoom level has been restored.
Indeed, if you look at the disassembly, the UIView retains its own zoom level (inside the UIGestureInfo object that the _gestureInfo field points to). It also has a set of good undocumented methods like zoomScale and setZoomScale:animated: (Keep in mind, he also has a bunch of rotation-related methods, maybe we'll get gesture support soon).
However, if we create a new UIView just for scaling and add our real scalable representation as our child, we will always start from scale level 1.0. My implementation of software scaling is based on this trick.
source share