iPhone如何设置视图颠倒模式

ike*_*rib 0 iphone xcode ios xcode4

我们开发了一个纵向模式的应用程序,没有支持acelerometer.

出于可用性,我们需要转180ºdeapp,因此我们需要在颠倒模式下使用该应用程序.我们检查xib属性,如果我们找到了一些神奇的东西来实现......没办法

任何,线索?任何帮助?

谢谢你

Syl*_*erb 5

如Steven Kramer所述,在视图控制器中定义它:

-(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
}
Run Code Online (Sandbox Code Playgroud)

例如,如果您只想接受横向模式,请使用

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
Run Code Online (Sandbox Code Playgroud)

仅限肖像,请使用 return UIInterfaceOrientationIsPortrait(toInterfaceOrientation);