-1

I've tried all morning, and start to think it's impossible.

So you have a touch in your screen, it entered the response chain and maybe did something. Then you moved it on the screen it called the touchesMoved: method (of the uiResponder associated with the touch) and maybe did other stuff. At this point, is there anyway, that the touch continues to move in the screen, and when it enters some other uiView, the uiTouch gets reinitialized (I mean, call touchEnded, in the first uiView, then in the new uiView call touchesBegan, and then if continues movement call touchesMoved).

I've tried to resignFirstResponder and to manually call the methods, and I just can't. I keep thinking that there should exist a really simple answer for this. Something like

UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self.superview];
if (!CGRectContainsPoint(self.frame, location)) {
    [touch restart];
}

or

[[touch phase] restart];

(But anything in documentation ):

Flores Robles
  • 656
  • 7
  • 14

1 Answers1

0

My recommendation would be to have the superview of all the views you want to transition through to receive the touches, then do a hit test on the subviews within the touchesMoved/Began/Ended methods (probably via CGRectContainsPoint(...)), and pass the touches along accordingly (calling the corresponding touchesBegan/Moved/Ended method on the subview).

Christian
  • 1,714
  • 8
  • 9
  • Thank you for the answer, but if the touch starts in view1, and move to view2, in view2 the method called will be touchesMoved. Is there any fast way for calling once touchesBegan in view2, and touchesEnded in view1? – Flores Robles Jun 06 '12 at 19:04
  • Well, with this solution, since you redirecting the methods to the subviews anyway, you can have your own logic. If we have view0 with viewA and viewB as the subviews, in view0's touchesMoved method, you can have something like ... if the previous touch was inside viewA and the new touch event is in viewB, send viewA touchesEnd and viewB touchesBegan. Else, send the new touch event the touchesMoved message. – Christian Jun 06 '12 at 19:24