objective c - How can I cancel a UIScrollView zoom bounce? -
i'm using zooming uiscrollview show images in ipad app. zooming works great, pinch making image smaller or bigger appropriate. have bounceszoom
enabled bounces minimum or maximum zoom if user stretches far 1 way or other.
now i'd recognize when pinch has ended image 10% smaller minimum zoom size and, in such case, prevent bounce happening , trigger different animation shrinks image "close" it. way, there can sort of "pinch close" gesture. i've come this, @ simplest, this:
- (void)scrollviewdidzoom:(uiscrollview *)scrollview { if (self.zoombouncing && zoomedtoscale / self.minimumzoomscale < 0.90) { // we've let go , under 90% of minimum size. self.minimumzoomscale = zoomedtoscale; [self shrinkimagetonothing]; } else { // how far have gone? zoomedtoscale = self.zoomscale; } }
this works great, except @ point it's bouncing, setting of minimumzoomscale
nothing. therefore, bounce , shrink occur @ same time, might imagine looks pretty weird.
so question is: how can prevent bounce happening in specific situation? there no uiscrollviewdelegate method allows code between when gesture finishes , when uiscrollview decides bounce back. i've tried bunch of other techniques no luck, including:
- returning
nil
–viewforzoominginscrollview:
when 90% zoom threshold has been passed. doesn't work because method called when gesture begins, not every point of zoom. - setting
bounceszoom
in-scrollviewdidzoom:
false when zoom factor less 90% , true when it's greater or equal 90%. makes image shake badly when scale gets under 90% because disallows size whenbounceszoom
false. - adding
-touchesended:withevent
method. never gets called. - adding own uipinchgesturerecognizer execute concurrently uiscrollview's own pinch recognizer. doesn't work because handlers (and delegate methods) called after uiscrollview's pinch gesture, makes decision bounce before gesture can tell not too. tried removing core gestures, adding mine, , adding core gestures back. gesture still called after uiscrollview had decided bouncing.
so i'm @ bit of loss. else tried this?
you have set property no. (ex. in viewdidload)
scrollview.bounceszoom = no;
Comments
Post a Comment