App中橫豎屏的設定

weixin_33860722發表於2016-09-06

本文主要論述橫豎屏設定的優先順序:系統設定>容器控制器設定>控制器設定.
iOS應用預設支援三個方向,具體設定如下:

1753235-4298b6d5e935406d.png
Snip20160906_2.png

在UINavigationController和UIViewController中都可以通過下面的方法設定頁面方向:

    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
        [[UIDevice currentDevice] setValue:@(UIDeviceOrientationLandscapeRight) forKey:@"orientation"];
    }

但是若在具體頁面設定的方向(假如設定了upsideDown選項),系統並不會響應設定.同理,UINavigationController中設定的方向,也會覆蓋其管理的UIViewController物件.

相關文章