Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Detect touchesBegan #79

Open
lucferbux opened this issue Aug 26, 2016 · 0 comments
Open

Detect touchesBegan #79

lucferbux opened this issue Aug 26, 2016 · 0 comments

Comments

@lucferbux
Copy link

When overriding the touchesBegan method in a category the scroll stop working. There is no easy way to detect a touch in the view.

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UIView * hitTestView = [self getNextResponderView:touches withEvent:event];
        [hitTestView touchesBegan:touches withEvent:event];
    }

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UIView * hitTestView = [self getNextResponderView:touches withEvent:event];
        [hitTestView touchesMoved:touches withEvent:event];
    }

    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UIView * hitTestView = [self getNextResponderView:touches withEvent:event];
        [hitTestView touchesEnded:touches withEvent:event];
    }

    - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UIView * hitTestView = [self getNextResponderView:touches withEvent:event];
        [hitTestView touchesCancelled:touches withEvent:event];
    }

    - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
    {
        return self;
    }

    - (UIView *)getNextResponderView:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UITouch * touch = [touches anyObject];
        CGPoint point = [touch locationInView:self];
        UIView * hitTestView = [super hitTest:point withEvent:event];
        return ( hitTestView == self ) ? nil : hitTestView;
    }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant