Rotate one UIViewController in UITabBar application

时光怂恿深爱的人放手 提交于 2019-12-01 01:59:46

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!