Rotate one UIViewController in UITabBar application

后端 未结 2 1427
谎友^
谎友^ 2021-01-07 15:31

I have uitabbar application and I Want to rotate just one ViewController with chart in landscape mode. It\'s possible to do that?

相关标签:
2条回答
  • 2021-01-07 15:45

    Only if it's modal, if it's part of the tabBarController, you need to support orientation change for all your controller

    0 讨论(0)
  • 2021-01-07 16:02

    There is no easy way to have only one view in landscape mode, while the others are in landscape, nor an easy way to programmatically switch to landscape mode.

    One possible approach would be using a CGAffineTransform to transform your view in your viewWillAppear (i.e., right before the view is shown):

    - (void)viewWillAppear:(BOOL)animated; {
       //-- Adjust the status bar
       [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
       //-- Rotate the view
       CGAffineTransform toLandscape = CGAffineTransformMakeRotation(degreesToRadian(90));
       toLandscape = CGAffineTransformTranslate(toLandscape, +90.0, +90.0 );
       [self.view setTransform:toLandscape];
    }
    

    Hope this works for you.

    0 讨论(0)
提交回复
热议问题