iOS app的橫豎屏設置非常簡單,在info.plist文件中進行修改就能控制。

但如果app中頁面的橫豎屏要求不一樣呢,就需要用到導航控制器進行控制。
寫一個navigation的類,實現兩個方法(以強制橫屏為例)
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
想要強制橫屏的頁面用navigation控制就行了,并且把導航條隱藏。新聞熱點
疑難解答