I have a set of images and would like to know what I touched. How could I implement this ...? More precisely: "Home Class" will create several classes of images:
Image *myImageView = [[Image alloc] initWithImage:myImage];
The image class looks something like this:
- (id) initWithImage: (UIImage *) anImage
{
if ((self = [super initWithImage:anImage]))
{
self.userInteractionEnabled = YES;
}
return self;
}
later, I use these touch-event-event methods also in the Image-class:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{}
My problem at the moment: by touch, the Began / Ended methods will run regardless of where I touched the screen, but I would like to know which of the images was affected .....
source
share