我们开发了一个纵向模式的应用程序,不支持加速度计。
为了可用性,我们需要将应用程序旋转 180º,因此我们需要应用程序处于颠倒模式。我们检查 xib 属性,如果我们发现一些神奇的东西来实现它......没办法
有线索吗?有帮助吗?
提前致谢
最佳答案
正如 Steven Kramer 所说,在您的 View Controller 中定义它:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
return YES to allow it or NO to forbid it
if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
return YES to allow it or NO to forbid it
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
return YES to allow it or NO to forbid it
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES to allow it or NO to forbid it
return NO; // Unknown value
}
例如,如果您只想接受横向模式,请使用
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
仅对于纵向,使用return UIInterfaceOrientationIsPortrait(toInterfaceOrientation);
关于iPhone 如何设置 View 倒置模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5990569/