03_知識點_橫豎屏適配

如果需要大部分界面只支持豎屏,部分頁面支持橫屏,需要這樣寫:

如果這幾個方法不起作用,那么估計是你的viewcontroller加在了nav中或tab中,再或者加入nav然后nav加入了tab,那么就要重寫nav或tab的這三個方法:

tab中:

- (BOOL)shouldAutorotate{

return [[self.viewControllers objectAtIndex:(int)self.selectedIndex] shouldAutorotate];

}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations{

return [[self.viewControllers objectAtIndex:(int)self.selectedIndex] supportedInterfaceOrientations];

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{

return [[self.viewControllers objectAtIndex:(int)self.selectedIndex] preferredInterfaceOrientationForPresentation];

}

nav中:

- (BOOL)shouldAutorotate{

return [self.viewControllers.lastObject shouldAutorotate];

}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations{

return [self.viewControllers.lastObject supportedInterfaceOrientations];

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{

return [self.viewControllers.lastObject preferredInterfaceOrientationForPresentation];

}

最后在需要橫屏或豎屏的controller中再重寫以上三個方法。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容