我有一组图片,想知道哪些被修改过。如何实现这个功能呢?更准确地说,一个“主页类”将实例化几个“图像类”:
Image *myImageView = [[Image alloc] initWithImage:myImage];
图像类大致如下所示:
- (id) initWithImage: (UIImage *) anImage
{
if ((self = [super initWithImage:anImage]))
{
self.userInteractionEnabled = YES;
}
return self;
}
稍后,我也在Image类中使用这些触摸事件方法:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{}
我目前遇到的问题是:无论我在屏幕的哪个位置触摸,都会触发touchesBegan/Ended方法,但我想找出哪个图像被触摸了.....
if (location.x >= img.frame.origin.x && location.x <= img.frame.origin.x + img.frame.size.width && location.y >= img.frame.origin.y && location.y <= img.frame.origin.y + img.frame.size.height)
? - Michael Hogenson