UIScrollview getting touch events

user559005 picture user559005 · Mar 7, 2011 · Viewed 50.5k times · Source

How can I detect touch points in my UIScrollView? The touches delegate methods are not working.

Answer

Suresh D picture Suresh D · Mar 7, 2011

Set up a tap gesture recognizer:

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)];
[scrollView addGestureRecognizer:singleTap];    

and you will get the touches in:

- (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture
{ 
    CGPoint touchPoint=[gesture locationInView:scrollView];
}