hariszaman February 2016

Specify Landscape image for resource iOS

when I create a new Imagese in Xcode I see the following screen missing landscape

Now I want to specify a separate image for iPad Landscape and iPad Portrait, but there is no such option available.

Offcourse I could do something like

-(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"];
} }

But I want to know if there exist any solution inside the interface builder or not?

Answers


Andrea February 2016

No there isn't.
Since the Xcode 6 version you can use size classes from image assets to specify a particular resource.
Unfortunately, iPad uses the same size classes (Regular-Regular) for both orientations. You can only do that programmatically by asking the status bar orientation and load the asset that you need.

Post Status

Asked in February 2016
Viewed 2,336 times
Voted 11
Answered 1 times

Search




Leave an answer