0

我有一个非常复杂的图表,我想在多个 TabBarController 和 NavigationController 中修复纵向 UIViewController,我在 UIViewController 中使用这段代码来修复 TabBar 和 Navigation:

@implementation UINavigationController (LoginIphone)

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

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

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

@end
@implementation UITabBarController (ChannelViewController)

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // You do not need this method if you are not supporting earlier iOS Versions
    return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

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

-(BOOL)shouldAutorotate
{
    return YES;
}

@end

并且里面的这段代码确实修复了 UIViewController但它不起作用。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskPortrait);
}

在此处输入图像描述

任何人都有这个问题的解决方案,感谢阅读这篇文章!

4

2 回答 2

0

你的supportedInterfaceOrientations方法应该是:

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
于 2013-07-24T04:23:48.807 回答
0

项目目标->单击“摘要”选项卡并在“支持的接口方向”中选择您的方向

于 2013-07-24T05:10:50.587 回答