I need to get the touch position from a UIScrollView. But when I create a subclass for my scrollview :
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSArray *touchesArray = [touches allObjects];
UITouch *touch = (UITouch *)[touchesArray objectAtIndex:0];
CGPoint point = [touch locationInView:self];
self.position = point;}
The function touchesBegan
isn't always called.
If I swipe fast, touchesBegan
is never called, but scrollViewDidScroll
gets directly called instead.
I can't use UIGesture (UITapGestureRecognizer, ... )
because users don't tap or swipe.
Are there others methods to get the position from UIScrollView ?
EDIT :
Thanks ThXou : https://stackoverflow.com/a/15763450/1752843
UIScrollView subclass :
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
self.position = point;
return self;
}