Turn one UIViewController in a UITabBar application

I have a uitabbar application and I want to rotate only one ViewController with a chart in landscape mode. It can be done?

0
source share
2 answers

There is no easy way to have only one view in landscape mode, while the other in landscape mode, as well as an easy way to programmatically switch to landscape mode.

One possible approach would be to use CGAffineTransform to transform your view into your viewWillAppear (i.e. right before the view):

 - (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.

+2
source

Only if it is modal, if it is part of the tabBarController, you need to support a change of orientation for your entire controller.

0
source

Source: https://habr.com/ru/post/1393019/


All Articles