質問

There are two views.

The first is an UIScrollView where the view to zoom is placed.
The second is an UIView which can handle taps on it.

Both views have gesture recognizers attached to them.

The problem is that even all gesture recognizers are turned off, scroll view won't zoom until I completely remove a view above (or set it userInteractionEnabled = NO). So how can I pass touches to scroll view and not lose other recognizers?

役に立ちましたか?

解決

I'd just add scroll's gesture recognizers to this custom view

@implementation CustomView

- (void)overridePinchForScroll:(UIScrollView *)scroll
{
    [self addGestureRecognizer:scroll.panGestureRecognizer];
    [self addGestureRecognizer:scroll.pinchGestureRecognizer];
}

@end

Note. You should add both pan and pinch gesture recognizers, because if you only add a pinch recognizer, it'll throw an error:

Ignoring call to [UIPanGestureRecognizer setTranslation:inView:] since gesture recognizer is not active.

And, of course, thus you'll still be able to drag zoomed content.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top