Question

I am a newbie in iOS-programming (trying to convert my android-app to iOS). I am using the storyboard and want to create a view, which has on the top a scrollview (with an ImageView inside) and on the bottom there is a TextView. This should be the View, if the users use the portrait-orientation.

Now I want that the ViewCOntroller in the landscape-orientation only shows the scrollview and the imageviews (that are inside the scrollview). The textview should be hidden in landscape. Is it possible to make the images bigger, but hold the aspect ratio ( in android:adjustViewBounds) ?

enter image description here

How can I handle this? I've tried it by using the "autosizing", but the result wasn't good.

Was it helpful?

Solution

Apple provides a method that is called when the app will change its orientation.

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        [textview setHidden:YES];
    } else {
        [textview setHidden:NO];
    }
}

Just add it to your view controller. Check more on Apple's reference

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