views:

120

answers:

1

I have an object that can be dragged around. Once the user's finger goes off screen and comes back, I loose the ability to drag the object. If the user then does another touch and drag, everything is fine.

How can I get notified once the user's finger drags back onto the screen? Since touchesBegan doesn't fire, I don't get any notification.

Here is my touchesMoved, which I call in the touchesBegan:

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];

    //stop object dragging at edge of screen
if(location.x > 35){
 myboject.center = location;}
}
A: 

The described behaviour seems normal to me, and all built-in Apple apps behave the same way. Since there’s no touch screen outside of the touch screen (yep), I believe there’s no way the device can distinguish between touch beginning or moving from outside of the screen.

Ilya Birman
As an example of how to get be continuous once the user's finger moves back onto the screen, look at the game Touch Tennis. If your finger slides off screen then back, the paddles continue moving. What event is triggered to recognize a move back onto screen rather than tap?
4thSpace
I don’t know, but I guess they just check for touchesBegan really close to the edge. Did you tried this?
Ilya Birman
You only get a touchesBegan when the user actually touches. It doesn't fire when you drag from off screen onto screen.
4thSpace
Oh, I didn’t get that from your question. I thought you wanted touchesBegan _not_ to occur and just continue getting touchesMoved. Sorry for my bad answer then :-) I guess you can edit the question to make the actual problem more clear. Good luck!
Ilya Birman
Actually, I've discovered this seems to be a simulator only issue.
4thSpace