I have an array with UIImageView. Let's say currently there's 5 UIImageView in the array. How do I know which UIImageView i'm currently touching?
Thanks.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
if ([touch view] == ??)
{
}
}
One of most simple solution is to set tag
properties of the views.
@property(nonatomic) NSInteger tag
This way you can easily retrieve the one touched :
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
if ([[touch view] tag] == 1)
{
// ...
}
}
You can set this property either in Interface Builder, or in code directly.