Shivbaba's son
Shivbaba's son

Reputation: 1369

what after only touches Began?

In my iPad app...

I am doing some stuff of dragging an object....

My problem is for dragging I need two methods...

  1. touches began some stuff1
  2. touches moved some stuff2

Sometimes what happens that the user is not moving the object after touching. So, whateever somestuff1 has been done. I need to reverse it back..

So,How would I do that...

enter image description here

Means is there any event or notification that I can fire

if the user does the touches began and not touches ended.

enter image description here

Upvotes: 0

Views: 193

Answers (2)

rob mayoff
rob mayoff

Reputation: 386058

You will always receive a touchesEnded:withEvent: message or a touchesCancelled:withEvent: message after you have received a touchesBegan:withEvent: message. You need to override both methods if you want to know when the user has lifted his finger.

If you want to track whether the user moved the touch before lifting his finger, you have to do that yourself. You can set a flag in your touchesMoved:withEvent: method, or you can save the original position of the touch in touchesBegin:withEvent: and then compare it with the final position of the touch in touchesEnded:withEvent: and touchesCancelled:withEvent:.

Upvotes: 5

Alexander
Alexander

Reputation: 8147

You have a - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event function, too, use it to check if the user hasn't made any moves.

Upvotes: 1

Related Questions