iOS 強制橫豎屏

強制橫屏

 NSNumber *resetOrientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationUnknown];
 [[UIDevice currentDevice] setValue:resetOrientationTarget forKey:@"orientation"];
 NSNumber *orientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
 [[UIDevice currentDevice] setValue:orientationTarget forKey:@"orientation"];

強制豎屏

NSNumber *resetOrientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationUnknown]; [[UIDevice currentDevice] setValue:resetOrientationTarget forKey:@"orientation"];
NSNumber *orientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:orientationTarget forKey:@"orientation"];

??

在執(zhí)行上述方法時要重寫controller的一下方法

//1,支持旋轉(zhuǎn)
-(BOOL)shouldAutorotate{
   return YES;
}
//2,支持的方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
   //所有方向
   return UIInterfaceOrientationMaskAllButUpsideDown;
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 在iOS軟件開發(fā)中,一般APP可能是需要全部橫屏或者豎屏,但是有的時候會遇到這樣的問題,就是我們的其中一個或者幾個...
    神經(jīng)騷棟閱讀 1,078評論 4 11
  • 最近在修改直播項目出現(xiàn)的問題,需要在直播頁面強制進入橫屏,記錄下遇到的坑,稍后會寫一篇阿里云直播的文章. 程序單獨...
    daihz閱讀 940評論 0 3
  • 概述 寫代碼就是在不斷填坑的過程中慢慢成長,程序員哪有不遇坑的呢? 這篇文章來談?wù)刬OS中橫豎屏切換的一些坑,橫豎...
    jumpingfrog0閱讀 11,512評論 6 21
  • iOS 中橫豎屏切換的功能,在開發(fā)iOS app中總能遇到。以前看過幾次,感覺簡單,但是沒有敲過代碼實現(xiàn),最近又碰...
    零度_不結(jié)冰閱讀 2,305評論 0 0
  • 01 入院 18床,收拾東西,可以出院了!護士大著嗓門朝我嚷道。 今天才發(fā)現(xiàn),平日里兇巴巴的護士笑起...
    家鄉(xiāng)雪韻閱讀 497評論 3 9

友情鏈接更多精彩內(nèi)容