Images to Target Specific iPhone Models - iphone

Say I have an image which is half the height of an iPhone 4s screen display, when this image is loaded to an iPhone 5 clearly this size is no longer half the size of the iPhone, as the iPhone 5's height is slightly larger then the iPhone 4s.
My question is, like using the image 2x and 3x, is there a way of adding images to your app that target specific iPhones? So that the other images not targeted will not be downloaded with the app.
Or will I need to add images of various sizes to the app and then in the code, say if iphone4 load this image, if iphone5 load this? The only reason I don't want to do this is because I will have 3x the amount of stored images (target iPhone 4, 5, 6) than I would for the iphone6 plus or iPad.
What I was hoping for something like image#2x~iphone4.png or image#2x~iphone5.png, but this doesn't work.

David Cao's answer is correct for bundled image assets, but you have mentioned that you don't really want to include this many assets with the app.
You may want to look at the App Thinning features of Xcode 7 / iOS 9, along with On-demand Resources this will allow you to load your required images into Xcode but the App Store would only download the resources required for the device being used.
If you still need to support iOS 8 you would need to have the images stored on a remote server and load them in when needed.

Take a look at image assets, it solves the exact problem you've stated.
https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/Recipe.html
What it does is allows you to provide 1x, 2x, and 3x images which can be referenced as a single name, when you call [UIImage imageNamed:#"imageNameHere"].

Related

Do I still need low-resolution images for using Interface Builder when developing iPhone app for iOS 7?

I started to develop an iPhone app for iOS 7.
Since iOS 7 does not support devices with non-retina display for the iPhone/iPod touch, and it uses high-resolution images on non-retina iPads (iPad 2 and iPad mini) in the iPhone emulation mode, now I think we don't need to provide low-resolution images when developing an iPhone-only app which deployment target is iOS 7.
I thought it's great, but soon I faced a problem when I used a Storyboard; apparently Interface Builder can not display high-resolution images which file names end with #2x.
I feel it's really pity that we have to provide the low-resolution images ONLY for the Interface Builder...
Is there any good workaround for this? Or do we still have to provide low-resolution images if we want to use the Interface Builder?
You are correct that an iOS 7 iPhone-only app is not going to run on any single-resolution devices, so you only need to provide double-resolution images. Do what you have always done in the past: refer to your image as myImage but name the actual image file myImage#2x.png. Even better, use the asset catalog! Place the double-resolution image in the 2x slot and refer to it by the name of that image set. Either way, this will work perfectly both in the storyboard editor and in the running app; in the storyboard editor, the Media Library and things like buttons that have images will display your image's name as myImage.

iTunes App Screenshots

I have an app that I am uploading to iTunes Connect, and I have loaded five hi-res iPhone 5 images (since it runs on iPhone 5). I know I have to also to have to load 640x960 images. However do I need to load 5, to be able to see 5 images on iTunes.
In this Apple Developer document, they only have one image for iPhone 5. In that case would only one image load, or would it also load the other 640x960 images? Would it also work the other way around?
I am asking primarily because I only have an iPhone 5 to test it on, and the Simulator's graphics are even comparable and scaling the images makes them look odd.
Any suggestions?
Thanks
No, iTunes only loads the screenshots for the screen size of the device it is being used on. On the computer, i'm pretty sure it loads the 3.5".

Suffix for Retina Images in iPhone 5

I have some image files for iPhone 5 size 640x1136, i have previously implemented retina images for iPhone 4 & 4S using #2x suffix, so what will be the suffix for images in iPhone 5, we can user the same as is #2x or it has to be changed.
It’ll still use #2x images where they’re available. There’s a -568h suffix you can use for the launch image, as in Default-568h#2x.png, but that’s currently the only place it’s supported; see Leo’s answer for a way to get that working elsewhere.
See my answer here. Some useful macros to help you with dealing with images.
For the iPhone Retina 4-inch (iPhone 5) it's still the #2x suffix because the density is the same as the iPhone Retina (iPhone 4 and 4S). The screen is bigger but have the same density.
The -568h suffix will work only in for the default image because it's the only place you really need it (just to tell the system that your app have been optimized for this new screen size, and it can stretch your views).
The naming convention Default-xxx.png is just here to provide the right image while the app is launching but I think it's non sense to try to replicate the same to load other images in imageViews. It's like the Default-(landscape|portrait).png on iPad. You never need this convention to load images yourself.
The only rule is:
# is for density (2 density exist right now, normal and 2x)
~ is for device (2 different devices exist right now, iphone and ipad)
To adapt images/imageView on the 4-inch iPhone you should play with your imageView content mode and the autoresizing configurations.

Application without support for older IPhones

I'm developing some app that it is not actually on iphones older than 4. So I have included in the project only #2x images, and have seted not to launch on iphone 3x and older. Is it ok not to include images without #2x suffix, cause it is not relevant? (I mean for AppStore)
The low res images are not required. Don't forget that the iPad can also run your iPhone app, and would be using non-retina images.
For memory purposes the OS uses the low-res pictures in older iPhones/iPods that's why it would need them. So if you are not supporting them you probably don't need them, I would recommend you to not add the suffix (just in case it messes up with something), just leave the original name of the image.
About supporting your app in the iPad, in the 2x mode your app will look a bit better because it will be using the high-res pictures instead of the low-res pictures.

What size images should I use in order to support the two iphone resolutions?

I have a few questions about screen resolution, that I'm not clear on. These questions assume they my app will be running on iOS 4.0 and up, and on either iPhone 3GS or iPhone 4.
Should the size of the splash image (default.png) be (960x640) or (480x320)?
Should the size of the app icon (Icon.png) be (57x57) or (114x114)?
What about other graphics that I may use in my app, such a graphic that represents a button? Should I always create these images for the higher resolution, and have the app scale them down? In other words, if I want a button image to be displayed on the 3GS that is 200x40 - should I create the image at 400x80, so that iPhone 4 can take advantage of it?
Thanks!
A good guide to this can be found here: http://mobile.tutsplus.com/tutorials/iphone/preparing-your-iphone-app-for-higher-resolutions/
In general you just create 2 sets of images. Your original and then a new one twice as big with #2x in the name. So for image.png at size 32x32 you would have one that is twice the resolution called image#2x.png at size 64x64. In your app just always use the image.png in Interface Builder and when loading in code.
There is no need to detect the device. These images will automatically be picked up by the OS and subbed in as necessary.
Provide both sizes (960x640 & 480x320) for the splash image using the #2x method described above
Provide both icons (57x57 & 114x114) using the #2x method
For our apps we use a combination of the #2x images and just Scaling the large images. (More information on this can be found in the above article) We use the #2x images for bar buttons, icons, etc. But for UIImageViews we often just use the Scaling. There can be a performance hit for doing this, but for most apps I'd say this is negligible. The savings in file size sometimes make scaling the only option.
Related Questions:
Retina/non-retina images in UIImageView
Making an app Retina Display friendly
You need to provide both if you want them to look nice. For example,
Default.png -> (480x320)
Amd
Default#2x.png -> (960x640)