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.