Is there a way to disable all of the UIPanGestureRecognizer
s that a touch effects? I am hoping to be able to isolate all touch events to one of my subviews and have every superview ignore all the touch events, but I can only determine this after touchesBegan:withEvent:
.
Is it possible to stop my superview's UIPanGestureRecognizer
s from interacting with a touch after it has triggered touchesBegan:withEvent:
?
To disable and re-enable panning in all superviews, you should do something like this:
- (void)recursivelyEnable:(BOOL)enable panGesturesInSuperview:(UIView *)superview
{
for(UIPanGestureRecognizer *recognizer in superview.gestureRecognizers)
{
if([superview isKindOfClass:[UIScrollView class]])[(UIScrollView *)superview setScrollEnabled:enable];
else [recognizer setEnabled:enable];
}
if(superview.superview)[self recursivelyEnable:enable panGesturesInSuperview:superview.superview];
}
and use it like so:
//Disable panning
[self recursivelyEnable:NO panGesturesInSuperview:self.superview];
//Enable panning
[self recursivelyEnable:YES panGesturesInSuperview:self.superview];
For some reason, you can't mess around with the UIGestureRecognizer
s of a UIScrollView
or any of it's subclasses; that is why I've included the check and alternative dis/enabling of panning.