簡體   English   中英

iOS-iPad Air和iPad Pro僅在橫向模式下強制設備定向

[英]iOS - iPad Air and iPad Pro force device orientation in landscape only

我試圖實現iOS應用程序特定的視圖控制器始終只打開橫向模式。 我在viewWillAppear中添加以下代碼。

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

上面的代碼可以很好地在以下設備上正常運行:iPhone 4s / 5 / 5s / 6 / 6s和iPad 2 / Retina。 但是iPad Air / Air 2 / Pro無法正常工作。 如何解決這個問題。 請指導我謝謝。

代替設備方向在ViewController中使用以下命令:

- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM