Rotating view controllers in the tab bar controller hierarchy & # 8594; Navigation Controller & # 8594; View controller

My application has a view controller hierarchy configured as follows:

UITabBarController
    |
    UINavigationController
    |  |
    |  UIViewController
    |
    UINavigationController
       |
       UIViewController

All my view controllers that are inside this hierarchy override the method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

and return YES- therefore, the view controller must be able to rotate before any rotation - even upside down.

However, in this setting, none of the view controllers will spin successfully. I got the impression that the navigation controllers and tab bars would rotate if their controllers represented rotation.

Why won't my view controllers spin?

, , - UINavigationController shouldAutorotate, , , -, , .

:

:

, shouldAutorotateToInterfaceOrientation: YES , . , shouldAutorotateToInterfaceOrientation: YES.

" " - , , , " ".

, , , - .

+3
5

, , . , "", , .

, , VC.

, (RotationTest GitHub), , , . , , - .

+4

Tabbarcontroller tabbarcontroller? ,

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

to

YES
0

, , - UINavigationController shouldAutorotate, , , -, , .

, , UITabBarController , UINavigationController. , UIViewController, , . UINavigationController, . , , , UINavigationController, , , . , . ( iPhone . IPhone , . - ​​ iPhone-. , iPhone .)

" " - , , , " ".

, HIG . .

, " " , , . "", , . , . : ( ) ? ( , , , .)

0

Subclass of UITabBarController as well as UINavigationController. It works using xCode 4.4.

0
source

I developed an extension that allows you to do this without a subclass of UITabBarController https://github.com/piercifani/TabBarBetterRotation

0
source

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


All Articles