iphone - iOS: Can I override pinch in/out behavior of UIScrollView? -
i'm drawing graph on uiview
, contained uiscrollview
user can scroll horizontally around entire graph.
now want zoom graph when user pinches in 2 fingers, instead of zooming in view same rate x , y direction, want zoom in x direction changing x scale, without changing y scale.
i think have catch pinch in/out gesture , redraw graph, overriding default zooming behavior.
but there way this?
i've been having difficult time catch pinch gesture on uiscrollview
, cancels touches when starts scroll. want zooming work after uiscrollview
cancels touches. :(
thanks, kura
although cannot delete existing pinch gesture recognizer, can disable , add own:
// disable existing recognizer (uigesturerecognizer* recognizer in [_scrollview gesturerecognizers]) { if ([recognizer iskindofclass:[uipinchgesturerecognizer class]]) { [recognizer setenabled:no]; } } // add our own uipinchgesturerecognizer* pinchrecognizer = [[uipinchgesturerecognizer alloc] initwithtarget:self action:@selector(pinch:)]; [_scrollview addgesturerecognizer:pinchrecognizer]; [pinchrecognizer release];
then in
- (void) pinch:(uipinchgesturerecognizer*)recognizer { .. }
use
[recognizer locationoftouch:0 inview:..] [recognizer locationoftouch:1 inview:..]
to figure out if user pinching horizontally or vertically.
Comments
Post a Comment