views:

18

answers:

1

hi,

i have 2 uiimageviews foo1,foo2 which are not intersecting each other, and i have 3 functions touchesBegan, touchesMoved, touchesEnded

- (void) touchesMoved:(NSSet *) touches withEvent:(UIEvent *) event
{
    UITouch *touch = [touches anyObject];

        if (foo1 == [touch view]){
       NSLog(@"foo1");
        }    

        if (foo2 == [touch view]){
       NSLog(@"foo2");
        }    
}

i'm holding touch on foo1 and move my finger to foo2, but from nslog i get foo1 message is there any possibility to determine in touchesMoved function when the touch goes on foo 2 ?

Thanks

A: 

It doesn't work this way by default. Once one view has "captured" a touch (in other words, once it's been hit-tested to be inside that view), the touch will "track" to that view until it is released, even if the touch's location goes outside the bounds of the view.

(My guess is that it may be possible to override this behavior with subtle overriding of the -pointInside:withEvent: and/or -hitTest:withEvent: methods, but I can't tell you how off the top of my head, and I'm actually not sure it's possible with these means.)

quixoto