开发者

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 withEve开发者_如何学编程nt:(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?


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


To get the touchesCancelled event, implement this method from UIResponder.

touchesCancelled:withEvent:.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜