I've got an inherited project with a bunch of code that uses -[UIImage imageWithContentsOfFile:]
and a full path. I'm converting it to use -[UIImage imageNamed:]
and just the file name (no extension) so I can pass it things like @"icon"
and get either icon.png
or icon@2x.png
or icon~ipad.png
, as appropriate.
The problem is, there's a part in the program where I want to check the size of the image and, if it's too big, I want to display, instead, TooBigImage.png
.
So I need to know, if I call [UIImage imageNamed: someName]
, which extended/modified name it's going to use. Basically, I want the path to that file, so I can check it's size before loading the image.
Alternately, if there's a way to check imageSizeForImageNamed:
or something similar, I'm ok using that, I just don't know of any.
I'd rather NOT re-implement the whole "if retina, append @2x, etc..." thing, as that's (a) cumbersome and (b) fragile (what if Apple changes/augments the behaviour?)
Hints?
Thanks!