Considering that the iPhone 4 has a much higher screen resolution than iPhone 3 -
How can I port my code to iPhone 4.
Won't recompiling it change the appearance of images, controls, etc.?
The provided UI elements should take care of the scaling for you. For anything you render, you'll need to take into account the screen resolution and scale accordingly. You might want to look at :
http://developer.apple.com/library/ios/#documentation/2DDrawing/Conceptual/DrawingPrintingiOS/SupportingHiResScreens/SupportingHiResScreens.html%23//apple_ref/doc/uid/TP40010156-CH15-SW1
I'm sure you already know this, but just in case you don't: you should be sure to include larger assets in your XCode project with #2x before their file extensions. For example: icon#2x.png. #2x tells iOS to use the larger version of the asset for Retina and iPad displays.
Related
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.
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.
I thought I read/saw/heard something saying that apps built for iPhone 4's Retina Display would automatically run at 640x960 when installed on an iPad. However, can't find any documentation on that specific feature, and my app still runs at 320x480 when installed on an iPad.
Is there a step I've missed to make this happen? Or did I just imagine this being a feature?
Apps do not auto-upscale, BUT if you have an image larger than the UIImageView you are placing it in, you will get as large a version as the iPad can draw.
I don't think it knows to pull in #2x images, just ones that are actually larger than the space you are placing them into.
This is not the case; currently, apps won't auto-upscale on an iPad. Perhaps Apple will add this in iOS 4.x for iPad, but certainly there's been no indication from them that they will.
In the apple docs it states
The portion is the
optional string #2x and should be
included only on images intended for
use on high-resolution screens
What are high-resolution screens? iPhone 4's? Do I need to include one?
I guess you missed the part where the iPhone 4 and it's double high resolution screen was introduced :-)
The iPhone 4 screen is 640 by 960.
To automatically take advantage of that you can provide graphics assets that have that #2x in the name.
When you use something like UIImage#imageNamed:, the OS will automatically use the high resolution image if appropriate.
It will also use those for the icons and launch screens if available.
They are all optional though. But I'm sure your users with an iPhone 4 will appreciate the high res artwork :-)
i just have a 3gs for testing (here in romania i still cant get a iphone 4)
When I just create full screen images for iPhone 4 .. would they be displayed resized on the 3gs?
I just cant make a bundle version for 3gs and 4 with 2 times my images, they are already a lot. Do I have to make now 2 Apps ??
Could this be a trick: In my xib i define a 320x480 UIImageView (it will be resized automaticly on the iPhone4) when I there define "scale to fill" and make high resolution images, would they come more sharp on the iPhone 4?
Now I am just wondering how to work best right now for big animations.
thx
Just found out in my case its fine to use higher resolution pics into a 320x480 frame like for 3GS and make Aspect FILL.
When I test on a iPhone 4 Simulator it shows much higher resolution and same on iPad if I click 2x :)
you can also create alternative high resolution images with a name ending in "#2x". so if you have an image called "arrow.png", create one with twice the resolution called "arrow#2x.png" and the iphone 4 will use that.
check out this article: http://thomasmaier.me/2010/06/dealing-with-iphone-4-resolution-2x-inside-of-photoshop/
Try it and find out, but my suspicion is that even if they do work, they won't work on OS 3.0 or OS 3.1, and plenty of people have not upgraded yet.
Also note that even if it displays them at half-size, I'm pretty sure that they'll still be "#2x" images. This means they'll use more memory and generally perform worse.
What's wrong with adding a handful of new images? The normal-size images are a lot smaller than the #2x images.
EDIT: If you have a lot of images, you may find it beneficial to use JPEGs where appropriate (e.g. for photos or photo-like backgrounds). I'm not sure, but I think they should work with +[UIImage imageNamed:] though you might have to specify ".jpg" explicitly.