Reputation:
I have a UIScrollview. In the UIScrollview there are 4 UIImageViews with images. When I click on any UIImageview I want to know the name of that image.
Upvotes: 1
Views: 2130
Reputation: 6052
UIImageView
just keeps the pointer to the place the UIImage
is stored inside the memory, so it's not possible with UIImageView
. You would need to create a subclass of UIImageView
with a NSString
variable which stores the value to access it later. Something like this:
#import <UIKit/UIKit.h>
@interface MyImageView : UIImageView
@property (strong, nonatomic) NSString *imageName;
@end
Upvotes: 4
Reputation: 8147
The image names are not stored in UIImage
objects so you have to keep them somewhere else for lookup. To detect touches in image views you either have to subclass them and add code for touch detection, add tap recognizers or replace them with buttons.
Upvotes: 1