views:

682

answers:

2

If I lift my finger up off the first touch, then it will recognize the next touch just fine. It's only when I hold my first touch down continuously and then try and touch a different area with a different finger at the same time. It will then incorrectly register that second touch as being from the first touch again.

Update It has something to do with touchesEnded not being called until the very LAST touch has ended (it doesn't care if you already had 5 other touches end before you finally let go of the last one... it calls them all to end once the very last touch ends)

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

 UITouch* touch = [touches anyObject];

 NSString* filename = [listOfStuff objectAtIndex:[touch view].tag];

// do something with the filename now

}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

 ITouch* touch = [touches anyObject];
 NSString* buttonPressed = [listOfStuff objectAtIndex:[touch view].tag];

 // do something with this info now
}
A: 

Set multipleTouchEnabled.

In Interface Builder, it's the "Multiple Touch" checkbox under "User Interaction Enabled."

Steven Fisher
tewha, you may be onto the right track here... I am creating the UIImageViews in code and setting MultipleTouchEnabled during that setup. For some reason, I'm not sure it's getting set properly. I have read elsewhere that if MultipleTouchEnabled is not set to YES, then touchesEnded will not get called until the very last touch has ended (which matches my error exactly!).
iWasRobbed
Nevermind, just checked that all were enabled and sure enough multipleTouchEnabled is YES for all :(Could it have something to do with all the UIImageViews being within a scrollview? Outside of the scrollview they do fine, but within the scrollview they don't send the message immediately.
iWasRobbed
A: 

For whatever reason, touchesEnded is being delayed only when the touch is within the scrollview. If you either a) disable the scrollview from scrolling; or b) don't use a scrollview, then touchesEnded gets delivered right away.

I have heard where some people have intercepted sendEvent, but that seems sketchy to me and I really don't want to screw up the responder chain since sendEvent handles an awful lot of events.

Any additional thoughts? Has anyone ever subclassed UIWindow to try and intercept the touches that way? Any input you could provide is appreciated.

iWasRobbed