Subview Gesture recognition issues while on scaling/scrolling view that is not at 1:1
-
29-04-2021 - |
Question
I have a UIScrollView that on it I have also created Gesture Recognizers. Tap, Double Tap, two finger tap, etc. On the Scroll View I create several other UIViews. Think of each of these views as Drawing objects. Circle, Squares, buttons, images, etc. Each of the Subviews I can pan, rotate, tap, etc and they all work for the most part.
If the Scaling Scroll View is not at 100% (1-1) then panning the subviews gets a bit sketchy. you can always tap them to get them to Highlight, though panning, rotation, etc is iffy. Typically if I try to pan a selected subview, it pans the scroll view. Sometimes it works, sometimes it does not. Set the zoom to 100%, or turn off the Scrolling (set scale to the same min/max), I can do what Is expected.
Any Suggestions on where to start troubleshooting this?
Solution
Not 100% why this works, but this is the code that made the issue disappear. I had to Subclass UIScrollView, override (BOOL)touchesShouldCancelInContentView:(UIView *)view
and return NO if the view was anything but the UIView
class for the UIScrollView.View
- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
BOOL returnVal = NO;
if ([view isKindOfClass:[IoScreenEditorContentView class]]) {
returnVal = [super touchesShouldCancelInContentView:view];
}
return returnVal;
}