I am going to addObject of 8 UIImageView * to a NSMutableArray. Each UIImageView is User Interaction Enabled.
When a user touches one of the UIImageViews, what is the best way to recall the index position of the selected UIImageView' i开发者_JAVA技巧n theNSMutableArray`?
I can imagine:
- sub-class
UIImageViewand add aNSUIntegerindex attribute - traverse the
NSMutableArrayand 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];
加载中,请稍侯......
精彩评论