Reputation: 1040
So the contentSize of my scrollView is initially equal to the frame of my image, but it seems that the more I zoom, the larger the contentSize gets. Thus, when the scrollView is zoomed in, , there is a huge gap around it. Dynamically updating the contentSize in - (void)scrollViewDidZoom:(UIScrollView *)aScrollView doesn't seem to work. Am I missing something?
Note: the gap is only visible vertically (i.e: above and below the imageView)
Upvotes: 3
Views: 3697
Reputation: 8608
I don't believe it is possible to update contentSize
on the fly while zooming
. This is because:
A scroll view also handles zooming and panning of content. As the user makes a pinch-in or pinch-out gesture, the scroll view adjusts the offset and the scale of the content. When the gesture ends, the object managing the content view should should update subviews of the content as necessary. (Note that the gesture can end and a finger could still be down.) While the gesture is in progress, the scroll view does not send any tracking calls to the subview.
You should update your contentSize
based on zoomScale
after the user has finished zooming
using:
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView
withView:(UIView *)view
atScale:(float)scale
Upvotes: 6