Possible Duplicate:
UIImageView – How to get the file name of the image assigned?
I can’t figure out how to find what image file an image view is displaying or if it is being displayed at all. For example lets say I have an image view. By the tag of the image view I want to be able to determine what file (the name of the file) is being displayed through the image view?
I can’t seem to find an answer to what I thing is a very simple question…
I know I can change the image of an imageview like this…
[(UIImageView*)[self.view viewWithTag:ImageViewTag] setImage:[UIImage imageNamed:imageTitle]];
But how can I see what image an image view is already displaying?
As the link in Ben’s comment explains, there is no native way to do this. However, you could easily create this behavior yourself.
You can subclass UIImageView and add a new instance variable:
Then you could override setImage, first setting imageFileName to the filename of the image you’re setting, and then calling [super setImage:imageFileName]. Something like this:
Just because it can’t be done natively doesn’t mean it isn’t possible 🙂