3

Recently I had a problem. How to disable scrolling in a particular area of a UIScrollView, particularly the area occupied by a UIView or subview. I've readen a lot about subclassing and other long approaches to solve this. But recently I solved this problem in a simplier manner without subclassing:

UIPanGestureRecognizer *panrecognizer = [[UIPanGestureRecognizer alloc] init];

and then

[panrecognizer setCancelsTouchesinView:NO];
[mySubViewInScroll addGestureRecognizer:panrecognizer];

I created the UIPanGestureRecognizer without an Action passed to it and then added the recognizer to the view in the scroller. In such way the gestures on the view will be captured but expressly not handled by the view or by the superviews because we passed to the object no Action. The question is this. Is this a correct approach to handle this type of prolem or it's better to do otherwise. I mean Apple will accept this kind of application with this approach ?

Claudio Ferraro
  • 4,551
  • 6
  • 43
  • 78
  • Can you clarify your question please: do you mean that you want a UIView laid over the top of the UIScrollView, i.e. not a child view of the UIScrollView, but just over the top (i.e. a sibling of the UIScrollView)? – occulus Nov 18 '11 at 00:47
  • Of course apple will accept this kind of app. So long as you don't start digging through their mountain of frameworks to find an undocumented (and most likely worthless) API for a scrollview, it'll be fine. – CodaFi Nov 18 '11 at 04:36
  • No..The UIView is a child of the UIScrollView. I wanna the UIview to not let his parent UIScrollView to scroll when we start to drag with fingers on the UIView itself, but when we drag in another part of the scrollview it scrolls normally and even the UIView moves with the rest of the scroll. – Claudio Ferraro Nov 18 '11 at 16:22

2 Answers2

0

try rewrite ScrollView's

-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

to return chi

LittleBobbyTables - Au Revoir
  • 32,008
  • 25
  • 109
  • 114
0

In effect I think that this, even if not the best is the most practical solution..since messing around with the classes and subclassing to achieve only a partial scroll lock of the screen seems to be very odd. So let-s see if Apple will accept this kind of solution...

Claudio Ferraro
  • 4,551
  • 6
  • 43
  • 78