我在 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/