Reputation: 98
i am using XCode 5 when i am naming the images like that :
fbicon~ipad.png [email protected]
Xib is getting the image
but when i am using this Convention
although tha naming convention is fbicon~ipad.png fbicon@2x~ipad.png
xib is not picking the images in that case.
Dont Know Why?
Upvotes: 1
Views: 4788
Reputation: 961
This is happening since you are using XIB. When used with XIB, for images to be used on iPhone one must use the convention "image~iphone" and for iPad you have to use "image~ipad". @2x is automatically appended based on which version (retina/non-retina) of the image is needed. That's why the first convention works for you.
In case of getting images from the code, e.g. if you have following versions of the "image"-
image~iphone.png
image~ipad.png
image@2x~iphone.png
image@2x~ipad.png
You just call-
[UIImage imageNamed:@"image"]
In this case, the second convention that you mentioned works- as detailed in the Apple doc- https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/LoadingResources/Introduction/Introduction.html So, nothing really wrong here as I see. For XIBs, the first convention is correct. For using with code, second convention is correct.
Upvotes: 4
Reputation: 10294
Migrate to use the assets catalogue. You just drag your images into the image wells and interface builder picks them up.
If the catalogue doesn't show the iPad iphone specific wells, open up the properties right side bar and tick the appropriate boxes.
Upvotes: 4