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

视图在iOS模拟器中被颠倒绘制,未正确检测到状态栏方向,ios,cocoa-touch,uiview,uiviewcontroller,autorotate,Ios,Cocoa Touch,Uiview,Uiviewcontroller,Autorotate,我在iPad上绘制了一个只支持横向的视图,但有时在iOS模拟器中,视图是颠倒的,iPad状态栏处于纵向模式。当我在模拟器中旋转设备时,一切正常,只是初始负载很奇怪。我正在使用CGRect设置视图,并使用标准的iOS坐标系 我的自动旋转方法: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return ((interfaceOrientation =

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

我的自动旋转方法:

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

那是你的代码片段中的一个输入错误;使用“| |”而不是“|”,因此:


那是你的代码片段中的一个输入错误;使用“| |”而不是“|”,因此:


或者更好地使用
返回UIInterfaceOrientationIsLandscape(interfaceOrientation)我更正了按位或键入错误,在设备上测试时没有遇到此问题,但它仍然发生在模拟器中。或者更好的是使用
返回UIInterfaceOrientationIsLandscape(interfaceOrientation)我纠正了按位或键入错误,在设备上测试时没有遇到此问题,但在模拟器中仍然会发生。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
  return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}