ios - View 在 iOS 模拟器中被颠倒绘制,未正确检测到状态栏方向

标签 ios cocoa-touch uiview uiviewcontroller autorotate

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

我的自转方法:

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

最佳答案

您的代码片段中是否有拼写错误?使用“||”,而不是“|”,所以:

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

关于ios - View 在 iOS 模拟器中被颠倒绘制,未正确检测到状态栏方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8746344/

相关文章:

iphone - 如何在不公开的情况下访问类中的其他类成员(ivars)?

ios - 如何以编程方式删除 plist?

ios - 使用自动布局在元素之间添加 UI 元素

android - 如何设置 ScrollView 以适应 React Native?

iphone - TTPhotoViewController:停用图库自动缩放

ios - 如何在本地存储 NSData

ios - 用户界面自动化 : Check if element exists before tapping

objective-c - 收到服务器响应后解析 UITableViewCell 中的 xml

iphone - uiview 中的 uiscrollview 不滚动

ios - 按需隐藏底栏