开发者

iPhone - Detecting touches and canceling them?

开发者 https://www.devze.com 2023-03-24 09:16 出处:网络
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?

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

精彩评论

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