I am going to addObject
of 8 UIImageView *
to a NSMutableArray
. Each UIImageView
is User Interaction Enabled.
When a user touches one of the UIImageView
s, what is the best way to recall the index position of the selected UIImageView' i开发者_JAVA技巧n the
NSMutableArray`?
I can imagine:
- sub-class
UIImageView
and add aNSUInteger
index attribute - traverse the
NSMutableArray
and compare eachUIImageView *
pointer
Is there an better alternative?
setting a tag would be the easiest way: [myImageView setTag:anIdentifier]; you could set the tag number as the same as the index in the array.
Or you could search for your imageView object in the array every time you need it: [myarray indexOfObject:myImageView];
精彩评论