【问题标题】:View being drawn upside down in iOS simulator, status bar orientation not properly detected在 iOS 模拟器中视图被颠倒绘制,未正确检测到状态栏方向
【发布时间】:2012-01-05 16:51:49
【问题描述】:

我正在 iPad 上绘制仅支持横向的视图,但有时在 iOS 模拟器中,视图被颠倒绘制并且 iPad 状态栏处于纵向模式。当我在模拟器中旋转设备时,一切正常,只是初始负载很奇怪。我正在使用 CGRect 设置视图并使用标准的 iOS 坐标系。

我的自转方法:

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

【问题讨论】:

    标签: ios cocoa-touch uiview uiviewcontroller autorotate


    【解决方案1】:

    那是您的代码 sn-p 中的错字吗?使用“||”,而不是“|”,所以:

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

    【讨论】:

    • 或者更好的是使用return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    • 我更正了按位或的错字,我在设备上测试时没有遇到这个问题,但它仍然在模拟器中发生。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-04
    • 1970-01-01
    • 2020-12-31
    • 1970-01-01
    • 2013-01-11
    • 1970-01-01
    相关资源
    最近更新 更多