I have a UIImageView that I allocated inside of a UIView. I want to double tap that subview using the TOUCHESENDED or TOUCHESBEGAN and send a callback or at least a log. I would appreciate anyone who can upload some code.
A:
As per the documentation, it is not recommended to subclass UIImageView
, but this is for drawing, if you only want to catch events, you may subclass UIImageVIew
and catch the event. Then look at the tapCount
property of the touch. As per http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UITouch_Class/Reference/Reference.html#//apple_ref/occ/instp/UITouch/tapCount
I don't know why, but I can't put that link not inline, it display correctly in JS preview, but not on the page.
2009-12-15 01:48:21
I actualy ended up initializing it as another king of view, then making a file to control that then put the touchesBegan method inside that .m file. Thanks
Jaba
2009-12-19 02:57:35
+1
A:
Here's how to use the .tapCount property inside touchesBegan:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
{
NSUInteger numTaps = [[touches anyObject] tapCount];
UITouch *touch = [[event allTouches] anyObject];
if ([touch view] == yourThing) {
NSLog(@"%i taps", numTaps);
}
}
willc2
2009-12-15 07:53:40