Get touches from UIScrollView
- by Peter Lapisu
Basically i want to subclass UIScrollView and hande the touches, however, the touch methods dont get called
(i searched the web for a solution and i found out people pointing to override the hit test, what i did, but with no result :( )
.h
@interface XScroller : UIScrollView
@end
.m
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView *result = nil;
for (UIView *child in self.subviews) {
if ([child pointInside:point withEvent:event]) {
if ((result = [child hitTest:point withEvent:event]) != nil) {
break;
}
}
}
return result;
}
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"BEGAN");
[super touchesBegan:touches withEvent:event];
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"MOVED");
[super touchesMoved:touches withEvent:event];
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"ENDED");
[super touchesEnded:touches withEvent:event];
}
- (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"CANCELED");
[super touchesCancelled:touches withEvent:event];
}
none of the - (void) touches* methods get called, the scrolling works ok