As many others, i am trying to implement a zooming behavior with the UIScrollView. I am using Auto Layout to layout my subviews.
In IB i have: ScrollView ImageView
The imageView has constraints to fill up the entire scrollView, so the image will be displayed in it's full size on load. This works like a charm. However, i cannot, for the life of me, figure out how to enable zooming. So far i have this code:
[_imgViewInScroll setImage:trackImg];
_scrImageViewer.scrollEnabled = YES;
_scrImageViewer.delegate = self;
_scrImageViewer.contentSize = trackImg.size;
_scrImageViewer.minimumZoomScale = 1;
_scrImageViewer.maximumZoomScale = 4;
And the implemented protocol:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
NSLog(@"Zooming");
return imgView;
}
But it doesn't work. The image is displayed, in full size filling the entire screen on load as expected, but it just won't respond to zooming at all. The NSLog statement gets executed, so it takes in the zooming request, but doesn't zoom.
What can i do? Thanks in advance.