在iOS 9中以编程方式锁定方向

hix*_*hix 5 device-orientation ios9

作为标题,我想知道现在可以在iOS 9中以编程方式锁定方向吗?这对我的应用程序至关重要,但我无法找到方法.谢谢.

Osw*_*eon 6

例如,使用supportedInterfaceOrientations和preferredInterfaceOrientationForPresentation来管理方向

-(UIInterfaceOrientationMask)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationPortrait;
}
Run Code Online (Sandbox Code Playgroud)