【问题标题】:Interface orientation to Landscape only界面方向仅横向
【发布时间】:2011-06-26 15:24:13
【问题描述】:

在我的视图控制器中,我实现了这个功能:

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

但我的视图控制器没有切换它的方向。我错过了什么?谢谢

【问题讨论】:

  • 如果你在该行设置断点,它会命中吗?

标签: objective-c ios cocoa-touch uiviewcontroller uiinterfaceorientation


【解决方案1】:

我这样做:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if (interfaceOrientation == UIDeviceOrientationLandscapeLeft ||  interfaceOrientation ==  UIDeviceOrientationLandscapeRight) 
    {
        return YES;
    }
    return NO;
}

这基本上就是您正在做的事情。确保 InterfaceBuilder 对横向模式也有您的看法。

【讨论】:

  • 感谢您的回复。我试过这个但没有用。我没有笔尖,一切都是以编程方式完成的。
猜你喜欢
  • 2011-05-16
  • 1970-01-01
  • 1970-01-01
  • 2016-05-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-27
  • 1970-01-01
相关资源
最近更新 更多