1.創建工程,設定Device Orientation 
2.在AppDelegate中實作下面這個方法:
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if (self.allowRotation) {
return UIInterfaceOrientationMaskLandscapeRight;
}
return UIInterfaceOrientationMaskPortrait;
}
此屬性默認是NO,在需要旋轉的界面將屬性設定為YES.
還沒有完,有人會問,那我如何去控制螢屏旋轉呢?別著急請往下看
一般我們手動控制螢屏橫豎屏切換肯定是需要觸發事件對吧!
那如何去手動控制螢屏旋轉呢?
在觸發旋轉事件中:
[AppDelegate sharedAppDelegate].allowRotation = YES;
self.navigationController.navigationBar.hidden = YES;
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
這樣就實作了強制旋轉某個試圖控制器,
如果想偷個懶,那么你出錢,我們出力.定制專屬于你的APP請咨詢我們:山東六牛網路科技有限公司
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/237672.html
標籤:其他
上一篇:SDK相關插件無法下載問題
