Changing Image quality for the iPhone 4 users in an iPhone app - iphone

I want to display an image to my users which is larger than the screen area and will overscroll to let the users drag it around and zoom in.
Do I need different images with different dpi for iPhone 4 users because of the higher resolution?
Or can I just set the zoom level differently depending on device?

Yes, you need to use different images. iOS 4 will automatically detect a higher-res image if you name it with a #2x suffix. e.g. image.png => image#2x.png
https://developer.apple.com/iphone/prerelease/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/SupportingResolutionIndependence/SupportingResolutionIndependence.html
(You must be a Registered iPhone Developer in order to see this document)

Related

Images to Target Specific iPhone Models

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"].

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.

The minimum number of launch images for a Universal App

I have a universal app which supports both orientations and all resolutions, so there are a bunch of possible splash images (iphone & ipad, portrait & landscape (left/right), retina & std display). But there is no sense to show anything except the background image as a splash image for my app. And the background is just a simple repeated pattern, so ideally I just specify a little 10x10 pixels image and tile the screen with it.
But as I understand it's not possible, and I need to provide a bunch of pre-rendered full-screen images. So I wonder what is the minimum number of images that is required for a Universal app? Will just one Default.png be enough?
In your case i would place 4 Default png's.
And yes. You need to pre-fill your 10x10 tiles in a (or multiple) big default.png files.
two for iPad (iPad / iPad Retina) and two for iPhone (iPhone / iPhone retina).
You need to set the base name in your app plist.
Look for Launch image (iPad) then enter there DefaultiPad (or something like this). Then you should place a DefaultiPad.png and a DefaultiPad#2x.png within your project resources.
Do the same for iPhone.
Look after Launch image (iPhone) in your app plist and do the same with a different base name.
Update 1:
You can also add Default.pngs for each device orientation.
Easiest way is to go with [Basename]-Landscapen.png and [Basename]-Portrait.png.
So in the case above you can place your files with the filename DefaultiPad-Landscape.png and DefaultiPad-Portrait.png
But this will also increase your binary filesize which – maybe for your 10x10 tile case - will not be worth doing so.
Because you are asking for the minimum:
Every app must provide at least one launch image. This image is typically in a file named Default.png that displays your app’s initial screen in a portrait orientation. However, you can also provide other launch images to be used under different launch conditions.
Source: App Launch (Default) Images
However, I also would suggest to use at least 4 (iPad + iPhone each in normal and #2x).
The minimum number you can provide is zero. If your app is quick to launch, you don't need to supply one. If your app is slow to launch, make it faster by putting heavyweight stuff on a background thread and get the UI (or a plain view with your tiled pattern) on screen as fast as possible.
You can't do it by just providing a small image and having it tile, you have to provide an actual, pre-made image for everything you want to support. In your case:
4 images for iPad (Landscape, Portrait, Landscape 2x, Portrait 2x)
2 images for iPhone (Portrait, Portrait 2x)
Left and right are the same image, unless you do something different with those orientations. Upside-down is the same too.
If you think that's a lot, wait until you see how many icons you need.
More info is at App Launch (Default) Images

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)

Is there any difference between iPad 2x mode and iPhone4 Retina display (for developer)?

Graphics development for iPhone4 and old iPhones was changed in several ways:
The concept of point was introduced
to replace pixel.
Methods of UIImage will load high
resolution resource files with #2x
in the file name.
Scale factor was added to UIScreen,
UIView, UIImage, and CALayer
classes.
So if we handle CGImage carefully, it's not hard to support the high resolution Retina display of iPhone4.
I have several questions about non-native iPad app in iPad 2x mode:
Could all the changes from old
iPhone to iPhone4 (#2x resources
auto loading, point concept, scale
factor) be applied to iPad 2x mode.
The scale of app on iPad can be
changed. How can I handle it?
With The new iPad sporting Retina Display you will need another set of images for some items such launcher icon, launch images (splash screen).
For example:
The launcher icon for Retina Display on iPhone/iPod Touch is 114 x 114 but on The new iPad the same icon for Retina Display is 144 x 144.
Other example:
On an Universal App, for the launch images (splash screen) you'll need an image set for phones/music players:
Default.png (For old devices)
Default#2x.png (For phones/music player with retina display)
Another image set for Tablets:
Default-Portrait~ipad.png (For original iPad and iPad 2)
Default-Portrait#2x~ipad.png (For the new iPad with retina display)
Default-Landscape~ipad.png
Default-Landscape#2x~ipad.png
The "#2x~ipad" will work on the new iPad in the same way "#2x" worked for the phones and ipods, but will be relative to the old iPad image set.
Unfortunately, all of those content scale functions were added in 4.0, so I don't think there's any way to use the iOS4 stuff that you're asking for.
The iPad 2x mode is just a way to run iPhone-only apps on the iPad's larger screen. If you want to take advantage of iPad's larger screen, all you have to do is create a universal binary (i.e. one that contains views for both iPhone and iPad).
There is no way to get the iPad 2x mode to display your iPhone retina level content automatically—Apple do not support this... presumably as they want people to put effort into developing iPad-specific interfaces for their apps.