【问题标题】:Orientation implementation issue Storyboard方向实施问题 Storyboard
【发布时间】:2015-05-01 23:10:35
【问题描述】:

我使用故事板并且有很多视图控制器。我在方向上面临问题。我尝试了提供stackoverflow的不同方法。但我没有得到任何答复。 Xcode 6.0 与 ios 8 有什么问题吗?

我的实现过程:

第 1 步:

我在 Newscontroller.m 中添加了以下代码

-(BOOL)shouldAutorotate {
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

- (NSUInteger)supportedInterfaceOrientationsForWindow:(UIWindow *)self{
    return UIInterfaceOrientationMaskPortrait;
}

现在的问题是……我需要禁用特定于方向的视图控制器,例如只保留纵向。有人有想法吗?

【问题讨论】:

    标签: objective-c iphone xcode swift storyboard


    【解决方案1】:

    我的测试和工作:

    在您的特定视图控制器中,只有这个:

    -(NSUInteger)supportedInterfaceOrientations 
    {
        return UIInterfaceOrientationMaskPortrait;
    }
    
    -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
        return UIInterfaceOrientationPortrait;
    }
    

    【讨论】:

    • 切断 shouldAutorotate 和supportedInterfaceOrientationsForWindow?这里工作正常。我做了一个版本
    • 非常感谢...但我正在使用 REFrostedViewController 侧菜单库...可能是库上的问题......我已经测试了示例示例。它正在工作
    【解决方案2】:

    1) 设置

    -(BOOL)shouldAutorotate {
        return YES;
    }
    

    2) 添加

    -(NSUInteger)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskPortrait;
    }
    

    就是这样:)

    【讨论】:

      猜你喜欢
      • 2011-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-16
      • 2013-09-16
      • 1970-01-01
      相关资源
      最近更新 更多