Using autolayout or the the old autoresizing masks is the way to solve the problem.
Marko has pointed the solution, but is missing something depending on your requirements. With the contentMode
you can play around to adapt the image to fit, or fill the bounds of the UIImageView
with or without keeping the aspect ratio.
One issue that I had in the past was to load 2 different images one for 3.5 inches and the other for 4 inches screen. Apple say that you can use this naming convention to load the correct image at runtime.
- name~iphone.png
- name@2x~iphone.png
- name~ipad.png
- name@2x~ipad.png
- name-568h@2x~iphone.png (iPhone 5)
It works well for retina and different devices (iphone or ipad), but the iphone5 convention works only for launch images.
Now there is only one opportunity left, check the screen size and load the correct one at runtime, in my opinion this is not an awesome solution.
In Xcode 5 thank to the Images asset functionality is possible to load the right image for a specific screen size. Just add a new image set, convert in the attribute inspector to device specific and just drag the images on their slot.