开发者

Getting image name from uiimageview

开发者 https://www.devze.com 2023-02-25 06:16 出处:网络
I want to get the particular image name by touching inside of that image. Can any one give me the samp开发者_高级运维le code for that? Nick Weaver is correct. There is still a way to do it, though.

I want to get the particular image name by touching inside of that image. Can any one give me the samp开发者_高级运维le code for that?


Nick Weaver is correct. There is still a way to do it, though.

Create an array with the names of the images. Set the tag property of each UIImageView so it corresponds to the names in the array. Then, access the array via the tag property.

NSArray *nameArray = [NSArray arrayWithObjects:@"image1", @"image2", nil];

//touch happened

NSString *imageName = [nameArray objectAtIndex:imageView.tag];

Another method is creating a UIImageView subclass.


UIImageView nor UIImage do store the name of the image you have used to create the image. You can subclass UIImageView and use your own initializer and an extra field to store the name.

0

精彩评论

暂无评论...
验证码 换一张
取 消