UIViewController and UISplitViewController in UITabBarController shouldAutorotateToInterfaceOrientation

I have some problems with my iPad code.

I have a UITabBarController that contains a UIViewController and a UISplitViewController. The problem is that the UIViewController and even the UISplitViewController do not recognize orientation changes correctly.

I set mustAutorotateToInterfaceOrientation on my TabBarController and all UIViewControllers, but I realized that only fireRotateToInterfaceOrientation in the Top moast ViewController will run, which is my TabBarController. If I remove shouldAutorotateToInterfaceOrientation from my TabBarController willRotateToInterfaceOrientation from my sub UIViewControllers will be called. The biggest problem is my UISplitViewController, because it will rotate to the new interface, but it is stuck in its Portrait layout.

How to implement TabBarController with ViewControllers and Splitviews, including orientation changes?

+3
source share
2
, . . "" .

TabBarController ro

- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [self adjustViewsForOrientation:toInterfaceOrientation];    
}

- (void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation {
    if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
        NSLog(@"Landscape");
        //Do Your Landscape Changes here


    }
    else if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
        NSLog(@"Portrait");
        //Do Your Portrait Changes here
    }
}

"viewControllers" TabBarController . , :

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    for (int i = 0; i < [self.viewControllers count]; i++ ) {
        [[self.viewControllers objectAtIndex:i] didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    }
}

didRotateFromInterfaceOrientation TabBarController:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
    [self adjustViewsForOrientation:self.interfaceOrientation];
}

- (void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation {
    if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
        NSLog(@"Subview Landscape");
        //Do Your Landscape Changes here
    }
    else if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
        NSLog(@"Subview Portrait");
        //Do Your Portrait Changes here
    }
}

, [self adjustViewsForOrientation:self.interfaceOrientation]; Sub Viewcontroller, Orientation . InInterfaceOrientation, , !

UISplitviewController TabBarController, , . , UIViewControllers. , , , 100%. -, cutsom Splitview. , , : http://blog.trustedones.com/development/ipad-uisplitviewcontroller-replacement-for-sethidesmasterviewinportrait http://www.trustedones.com/apps/ipad

SplitView , . !

, - . nettz

0

, UITabBarController : " ".

, , , "". ( .)

0

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


All Articles