Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto Rotate while switching between View Controllers

I have a problem in programming. I have two view controllers. The first runs only in landscape left / right, the other runs only in portrait. If I switching between the views the orientation do not change automaticly. Only when I turn the device the orientation is changing. After that the orientation is fixed. Is it possible to change the orientation automaticly when I switching between the controllers?

As Example when I press the BackButton in the Landscape View Controller and it switch to the Portrait View Controller that the orientation automaticly switch from Landscape to Portrait?

Sorry for my bad english, it is not my native language.

Thanks, Tim

like image 375
user1629827 Avatar asked Feb 12 '26 08:02

user1629827


1 Answers

Try the following Code for Portrait in Second View.

- (void)viewWillAppear:(BOOL)animated {
    [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];

}

Try the following Code for Landscape in First View.

 - (void)viewWillAppear:(BOOL)animated {
        [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscape];

    }
like image 83
Siba Prasad Hota Avatar answered Feb 15 '26 00:02

Siba Prasad Hota



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!