UITabBar autorotation problem

I am wondering why the iPad project based on UITabBarController will not autorotate when I indicate that some tab should autorotate in landscape mode, and another will autorotate in landscape and portrait modes.

I used

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

for all UIViewController and specify if the terrain return YES; another wise return NO;

On the other hand, if the UIViewController should rotate in landscape and portrait i've just returns YES; `always.

thanks in advance.

+4
source share
1 answer

for all the UIViewController that you load into the tabbarcontroller, you should return True in

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

Note: The tab bar controller will not automatically rotate if ALL the controllers it contains also will not rotate automatically.

from Turn one UIViewController in a UITabBar application →>

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 convert 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]; } 
+4
source

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


All Articles