How would I go about zooming multiple subviews of an UIScrollView simultaneously? I have a UIScrollView inside another UIScrollView (with paging enabled) and inside the inner scrollview I have four UIImageViews. I would like for the zoom to persist when I scroll to the next page, thus displaying the next image.
Relevant code follows:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return self.page2;
}
+(void)updateScale:(CGFloat)newScale{
currentScale = newScale;
}
+(CGFloat)getScale{
return currentScale;
}
from the outer, paging enabled, scroll view and
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return imageView;
}
-(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale{
[PhotoViewController updateScale:scale];
NSLog(@"New scale set to %01f", scale);
NSLog(@"This should be equal to %01f", [PhotoViewController getScale]);
}
from the inner scrollview.
currentScale is updated correctly according to the log output, but when I call [page setZoomScale:[PhotoViewController getScale]]; for the updated page variable, nothing happens. page is allocated and initialized correctly.
Just put all of your image views into an empty UIView, and add that view to your scroll view.