【问题标题】:force UIViewController to be in Landscape mode iOS7强制 UIViewController 处于横向模式 iOS7
【发布时间】:2014-03-04 03:53:53
【问题描述】:

我已经实现了正确的功能,但它们没有被触发?我在 StackOverFlow 上尝试了几种解决方案,但没有一个有效。我已经尝试将视图添加到 UINavigationController,也不起作用。

FakeIDDetailViewController.h:

@interface FakeIDDetailViewController : UIViewController
@end

FakeIDDetailViewController.m:

@interface FakeIDDetailViewController ()

-(BOOL)shouldAutorotate
{
    return NO;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (UIInterfaceOrientationMaskLandscapeLeft);
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}

- (NSUInteger) application:(UIApplication *)application     supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return UIInterfaceOrientationLandscapeLeft;
}

【问题讨论】:

标签: objective-c xcode uiviewcontroller orientation


【解决方案1】:

如果您将视图控制器推送到导航控制器中的其他视图控制器堆栈,则仅需要横向将无法正常工作。您应该以模态方式显示横向约束视图控制器。

在此处查看我的答案以获取示例项目: https://stackoverflow.com/a/16022631/983912

【讨论】:

    【解决方案2】:

    对于导航控制器界面,框架不支持强制定向。在这里查看我的答案:https://stackoverflow.com/a/15301322/341994

    有关解决方法(不是很好),请在此处查看我的答案:https://stackoverflow.com/a/16379515/341994

    但是,对于呈现的视图控制器,强制方向可以正常工作。

    【讨论】:

      猜你喜欢
      • 2015-06-23
      • 1970-01-01
      • 2011-07-17
      • 1970-01-01
      • 2014-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多