我有一組圖像,並想知道我曾經觸摸過哪些圖像。我怎麼能實現...? 爲了更準確: 「家級」將實例一對夫婦形象 - 類:objective-c觸摸事件
Image *myImageView = [[Image alloc] initWithImage:myImage];
圖像類看起來是這樣的:
- (id) initWithImage: (UIImage *) anImage
{
if ((self = [super initWithImage:anImage]))
{
self.userInteractionEnabled = YES;
}
return self;
}
後來,我用這些觸摸事件的方法也是在圖像類:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{}
我此刻的問題:的touchesBegan /已結束的方法將在那裏我被感動無論解僱屏幕上,但我想知道哪些圖像已被觸摸.....
我知道這是舊的,但不應該有條件的,'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)'? – 2014-01-22 22:42:24