So I have a UIScrollView
with the zooming functionality delegated to a view controller which of course overrides:
- (UIView*)viewForZoomingInScrollView:(UIScrollView*)scrollView { ... etc ...
and everything works (it zooms and scrolls).
Then I took it up a notch an added two other UIScrollViews to the top level view whose purposes is to act as guides for a grid (think rows and columns in M$ Excel for example).
Therefore one of the scrollView's subview contains a row of UILabel
s (A, B, C, D...) and the other is identical except the UILabel
s are in a column (1, 2, 3, 4...). Picture a chess board if this helps.
Now I connected the vertical and horizontal scrolling of the main scrollView to the guide scroll views like so:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView == self.scrollView) {
self.verticalGuideScrollView.contentOffset = CGPointMake(0, scrollView.contentOffset.y);
self.horizontalGuideScrollView.contentOffset = CGPointMake(scrollView.contentOffset.x, 0);
}
}
And everything works.
I connected the zooming functionality of the scrollView's like so:
- (void)scrollViewDidZoom:(UIScrollView *)scrollView
{
if (scrollView == self.scrollView) {
self.verticalGuideScrollView.zoomScale = scrollView.zoomScale;
self.horizontalGuideScrollView.zoomScale = scrollView.zoomScale;
}
}
and that also works fine EXCEPT I don't actually want it to enlarge the subviews (i.e the UILabel
s) in the guide views, I merely want the translation behaviour that comes from zooming without the scaling (enlarging or shrinking).
I can envision a solution by adding a UIPinchGestureRecognizer
to the main scrollView and using that to translate all the subviews in the guide scroll views but perhaps someone here can come up with something simpler.