使用UITabBarController管理UINavigationController时,Push出第三个界面时怎么横屏?


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


 - (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}

uinavigationcontroller uitabbarcontroller ios 横屏 push

九头教教主 11 years, 6 months ago

UINavigationController的回调是有效的,viewcontroller只有一个回调是必要的,忘了那个了。你两个都写把。其实就是你顶层的viewcontroller也要控制。

Kensei answered 11 years, 6 months ago

我之前是这么做的:
添加UITabBarController、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];
}

人不猥琐枉少年 answered 11 years, 6 months ago

Your Answer