gpt4 book ai didi

ios - "interfaceOrientation"在 iOS 8 中已弃用,如何更改此方法 Objective C

转载 作者:IT老高 更新时间:2023-10-28 11:25:05 25 4
gpt4 key购买 nike

我从 Cocoa Controls 下载了一个使用此方法的 simpleCamera View

- (AVCaptureVideoOrientation)orientationForConnection
{
AVCaptureVideoOrientation videoOrientation = AVCaptureVideoOrientationPortrait;
switch (self.interfaceOrientation) {
case UIInterfaceOrientationLandscapeLeft:
videoOrientation = AVCaptureVideoOrientationLandscapeLeft;
break;
case UIInterfaceOrientationLandscapeRight:
videoOrientation = AVCaptureVideoOrientationLandscapeRight;
break;
case UIInterfaceOrientationPortraitUpsideDown:
videoOrientation = AVCaptureVideoOrientationPortraitUpsideDown;
break;
default:
videoOrientation = AVCaptureVideoOrientationPortrait;
break;
}
return videoOrientation;
}

问题是 iOS 8 中不推荐使用“interfaceOrientation”,但我不知道在 Switch 条件下用什么以及如何替换它。

最佳答案

获取设备方向不正确。例如,设备可能处于横向模式,但仅支持纵向的 View Controller 将保持纵向。

改用这个:

[[UIApplication sharedApplication] statusBarOrientation]

另一个好处是它仍然使用 UIInterfaceOrientation 枚举,因此您的代码几乎不需要更改。

关于ios - "interfaceOrientation"在 iOS 8 中已弃用,如何更改此方法 Objective C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28787165/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com