ADBlock is blocking some content on the site

ADBlock errore

Question about using landscape mode with custom images on the iPhone/iPad

StackOverflow https://stackoverflow.com/questions/2216012


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!


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


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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow