I'm trying to get notified when UIScrollView
is pinch zoomed out beyond its minimum zoom limit and is about to animate back, but I'm finding it very difficult. Is there a way I can do this with delegate
methods alone or do I need to override UIScrollView's
touch handling?
Use scrollViewDidZoom:
and check if scrollView.zoomBouncing == YES
. Then use zoomScale
to determine which direction the view is bouncing.
- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
if (scrollView.zoomBouncing) {
if (scrollView.zoomScale == scrollView.maximumZoomScale) {
NSLog(@"Bouncing back from maximum zoom");
}
else
if (scrollView.zoomScale == scrollView.minimumZoomScale) {
NSLog(@"Bouncing back from minimum zoom");
}
}
}
You can use UIScrollView's scrollViewDidZoom
delegate method to detect the moment it's about to animate back. You'll see scrollView.zoomScale
drop below scrollView.minimumZoomScale
while the view is being pinched. Then, as soon as the user releases their fingers, scrollViewDidZoom
will be called once again with scrollView.zoomScale == scrollView.minimumZoomScale
, but scrollView.zooming == NO
.
Capturing this moment is fine and all, but attempting to do anything to preempt the bounce-back-to-minimumZoomScale animation seems to have really odd side effects for me. :(
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With