本文主要論述橫豎屏設(shè)置的優(yōu)先級:系統(tǒng)設(shè)置>容器控制器設(shè)置>控制器設(shè)置.
iOS應(yīng)用默認支持三個方向,具體設(shè)置如下:
Snip20160906_2.png
在UINavigationController和UIViewController中都可以通過下面的方法設(shè)置頁面方向:
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
[[UIDevice currentDevice] setValue:@(UIDeviceOrientationLandscapeRight) forKey:@"orientation"];
}
但是若在具體頁面設(shè)置的方向(假如設(shè)置了upsideDown選項),系統(tǒng)并不會響應(yīng)設(shè)置.同理,UINavigationController中設(shè)置的方向,也會覆蓋其管理的UIViewController對象.