iosobjective-ciphoneuitouchtouchescancelled

iPhone - Detecting touches and canceling them?


I am dtecting touches on my UIView. Is some situations I want to be abel to cancel touches so that touchesEnded won't get called. But doesn't matter what touchesEnded will always get called?

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
   if (SOMETHING_SPECIAL)
   {
      [super touchesCancelled:touches withEvent:event];
   }
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
   //I don't want it to get here if touches were canceled how can i do this?
}

- In my touchesEnded how can I determine whether touches were canceled or not?


Solution

  • TouchesEnded will always get called wherever your touches where canceled or not, so I would suggest instead having that exact:

       if (SOMETHING_SPECIAL)
       {
    
       }
    

    In your:

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