仅适用于iPad的纵向方向?

Nex*_*Rev 3 xcode portrait orientation ipad

根据apple,我的应用程序必须能够以两种肖像模式运行.如何使用shouldAutorotateToInterfaceOrientation完成此操作?

ken*_*ytm 8

无论接口方向是什么,只需返回YES.这将允许系统自动旋转到倒置方向.

如果您不想支持横向方向,请返回:

return UIInterfaceOrientationIsPortrait(interfaceOrientation);
Run Code Online (Sandbox Code Playgroud)


pro*_*rmr 6

此代码允许除横向以外的任何方向:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
    return (orientation != UIDeviceOrientationLandscapeLeft) &&
           (orientation != UIDeviceOrientationLandscapeRight);
}
Run Code Online (Sandbox Code Playgroud)

  • 这个答案被低估了. (2认同)