views:

653

answers:

2

Hey I just had a simple question about implementing landscape mode for an app, particularly running on the iPad (but I am sure the concept holds true for the iPhone). I have a custom background image that I am wanting to use for my root view. I designed the image so that it fits the iPad screen size for portrait mode. Do I need to design a second image for landscape mode so that it fits correctly? Is that how the landscape/portrait transition works, switching between two different images? I really don't have any idea, so any help would be appreciated. Thanks!

A: 

Assuming you have a UIImageView as your backdrop, change its image property after the device orientation changes.

See Handling View Rotations in http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html

Lachlan Roche
Thanks! I knew it was simple, I just needed a point in the right direction.
Steve
+1  A: 

One other thing to think about is that the UIImage class has stretchableImageWithLeftCapWidth:topCapHeight: method to take an existing image, and build a new image that can adjust to any size by repeating only the central portion of the image and leaving the corners of the image as fixed image segments.

You can load in a fixed UIImage, generate a stretchable copy using this method, and assign it to a UIImageView - then as you resize the UIImageView due to rotation, the image will adjust as needed and not resample the image.

Kendall Helmstetter Gelner
Hey thanks for that. I am assuming this means I don't necessarily need to re-engineer another image for the other orientation. Will there be any loss of quality in the image? Thanks
Steve
There should not be any loss of quality, as long as the image is created so that the middle pixels can be used or omitted as needed.
Kendall Helmstetter Gelner