我在iPad上绘制了一个仅支持横向方向的视图,但有时在iOS模拟器中,视图被颠倒绘制,iPad状态栏处于纵向模式。当我在模拟器中旋转设备时,一切都表现正常,这只是初始负载很奇怪。我正在使用CGRect设置我的视图并使用标准的iOS坐标系。
我的自动旋转方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) | (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
答案 0 :(得分:1)
这是您的代码段中的拼写错误;使用“||”,而不是“|”,所以:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}