Search code examples
iphoneobjective-ciosuigesturerecognizeruitouch

UIGestureRecognizer that cancels when touchup outside of targetView


I have a UIView of which I want to know when the user is doing:

touchDownInside (to highlight the view)

touchUpInside (to confirm the action)

touchUpOutside (to cancel and reset the hightlight)

what gestureRecognizer can do this for me?


Solution

  • Please go though these four methods also which your view can override to handle the four distinct touch events:

    1) finger or fingers touches the screen

    -(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event;
    

    2)finger or fingers move across the screens(this message repeatedly as a finger moves.)

    -(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event;
    

    3)finger or fingers is removed from the screen

    -(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event;
    

    4) a system event,interrupts a touch before it ends

    -(void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event;