Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Image Name used in an UIImage?

I am using an UIImage, in which I have an Image, and I want to know the name of image.

like image 947
Eager Beaver Avatar asked Apr 23 '12 11:04

Eager Beaver


4 Answers

That functionality is not built-in to UIImage because images are not always loaded from files. However, you could create a custom UIImageView subclass to fit your needs.

like image 55
Evan Mulawski Avatar answered Oct 12 '22 08:10

Evan Mulawski


It is not possible. UIImage instance contains the actual image data without any reference to the filename.

like image 21
Krishnabhadra Avatar answered Oct 12 '22 08:10

Krishnabhadra


Images do not necessarily come from files or other named sources, so not all images even have a name. When you create an image from a file, you could store the name in a separate NSString*, and then refer to that stored name when necessary.

like image 35
Sergey Kalinichenko Avatar answered Oct 12 '22 08:10

Sergey Kalinichenko


this code will help you out

    NSString *imgName = [self.imgView1st image].accessibilityIdentifier;

    NSLog(@"%@",imgName);

    [self.imgView2nd setImage:[UIImage imageNamed:imgName]];
like image 32
junaidsidhu Avatar answered Oct 12 '22 08:10

junaidsidhu