ios - 使用UITabBarController管理UINavigationController时,Push出第三个界面时怎么横屏?
怪我咯
怪我咯 2017-04-17 13:37:49
0
3
642

在push出的viewcontroller里面 下面方法不会被执行

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}
怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(3)
黄舟

This is what I did before:
Add categories of UITabBarController and UINavigationController

UITabBarController (xxx)

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [self.selectedViewController preferredInterfaceOrientationForPresentation];
}

- (BOOL)shouldAutorotate
{
    return [self.selectedViewController shouldAutorotate];
}

- (NSUInteger)supportedInterfaceOrientations
{
    return [self.selectedViewController supportedInterfaceOrientations];
}

UINavigationController (xxx)

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [self.topViewController preferredInterfaceOrientationForPresentation];
}

- (BOOL)shouldAutorotate
{
    return [self.topViewController shouldAutorotate];
}

- (NSUInteger)supportedInterfaceOrientations
{
    return [self.topViewController supportedInterfaceOrientations];
}
巴扎黑

The callback of UINavigationController is valid, only one callback of viewcontroller is necessary, forget that one. You write both. In fact, your top-level viewcontroller also needs to be controlled.

左手右手慢动作

Could you please tell me what the correct approach is? I did the above but it still doesn’t work?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template