iphone: Forcefully change orientation from portrait to landscape on navigation

前端 未结 3 1266
名媛妹妹
名媛妹妹 2021-01-06 16:07

Is there any way that we can Forcefully change app orientation from portrait to landscape while navigating ?

I have a requirement that while pushing controller from

3条回答
  •  被撕碎了的回忆
    2021-01-06 17:04

    In your ViewController-B add this lines of code in viewDidLoad:

      [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
    
      float   angle = M_PI/2;  //rotate 180°, or 1 π radians
      self.view.layer.transform = CATransform3DMakeRotation(angle, 0, 0.0, 1.0);
    

    This code is working fine if you are using navigation controller to move from A to B.

    I have used this.

    Hope this will help you.

    Enjoy Coding :)

提交回复
热议问题