Question

I have a view controller with a UIImage View that loads a different .png depending on orientation. It loads both images but 1) the landscape view is compacted and is not scaling properly, and 2) when I run it in simulator and turn it to the right twice (command + ->) it is vertical again and should display the portrait image, but it instead displays the landscape image sideways. Any ideas? My .m method is below:

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

Are there more orientations I'm missing? Is there a way to have the portrait as is ("scale to fill") but somehow get the landscape to appear properly too? For what it's worth, the landscape appeared properly on iOS6, but is now poorly scaled on iOS7. The issue with the two rotations = sideways landscape was present in iOS6 as well. Thanks.

Was it helpful?

Solution

I simply didn't have upside down supported as an orientation in the info.plist, which solved the rotation issue.

As for the scaling of the landscape views, it took a great deal of messing around with autolayout and setting constraints. No particular silver bullet worked here - just playing aroud with it til it looked like I wanted. So all good in this question.

However, when the initial orientation is landscape and I switch to another view, I run into issues, but I've put that up in another question.

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