views:

51

answers:

1

Hello

I'm developing an app for iPad and I try to handle multiple orientation. My app contains a webview and a loading UIImageView that appears when my webview is loading content.

This UIImageView has a background image that I set in InterfaceBuilder. When I change orientation to landscape, the image is cut.

I'd like the UIImageView to set image-portrait.png when the ipad is in portrait mode and image-landscape.png when it's in landscape mode.

Thank you for your help and advices!

Screenshots :

alt text alt text

A: 

I found a solution :

In Interface Builder, I set the autosizing of my ImageView to auto fill the screen. In my ViewController, I add a method to detect the change of orientation and I set the appropriate image depending if the iPad is in portrait or landscape :

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight)){
    myImageView.image = [UIImage imageNamed:@"image-landscape.png"];
} else  if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown)){
    myImageView.image = [UIImage imageNamed:@"image-portrait.png"];
} }
Salah