AVCaptureVideoPreviewLayer显示错误的方向
创始人
2024-11-12 22:30:27
0

在设置AVCaptureVideoPreviewLayer时,需要设置layer的videoGravity属性为AVLayerVideoGravityResizeAspectFill,并根据设备的方向进行调整。

示例代码:

AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:captureSession];
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
previewLayer.frame = self.view.bounds;

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationPortrait) {
    previewLayer.connection.videoOrientation = AVCaptureVideoOrientationPortrait;
} else if (orientation == UIDeviceOrientationPortraitUpsideDown) {
    previewLayer.connection.videoOrientation = AVCaptureVideoOrientationPortraitUpsideDown;
} else if (orientation == UIDeviceOrientationLandscapeLeft) {
    previewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight;
} else if (orientation == UIDeviceOrientationLandscapeRight) {
    previewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;
}
[self.view.layer addSublayer:previewLayer];

相关内容

热门资讯

透视神器!悦扑克脚本,wepo... 透视神器!悦扑克脚本,wepoker透视脚本下载,新版2025教程(有挂技巧)1、玩家可以在wepo...
透视规律!wepoker私人局... 透视规律!wepoker私人局辅助挂,wepoker透视脚本苹果版(透视)详细教程(有挂方法)1、进...
透视能赢!wepoker插件辅... 透视能赢!wepoker插件辅助,购买的wpk辅助在哪里下载,普及教程(有挂详情);1)购买的wpk...
辅助透视!wepoker有辅助... 辅助透视!wepoker有辅助工具吗,wepoker私人局辅助器怎么用(透视)必胜教程(有挂攻略)1...
透视辅助!wepoker脚本,... 透视辅助!wepoker脚本,智星德州有脚本吗,可靠教程(有挂秘笈)1、智星德州有脚本吗系统规律教程...
透视辅助!wepoker怎么拿... 透视辅助!wepoker怎么拿到好牌,wepoker有透视功能吗(透视)详细教程(有挂详情)进入游戏...
透视存在!约局吧德州真的有透视... 透视存在!约局吧德州真的有透视挂吗,sohoo竞技联盟辅助器,教你攻略(有挂方法)1、约局吧德州真的...
透视规律!聚星ai辅助工具收费... 透视规律!聚星ai辅助工具收费多少,wejoker辅助软件视频,2025新版技巧(有挂详情)1、聚星...
透视智能ai!we-poker... 透视智能ai!we-poker正规吗,wepoker辅助透视(透视)攻略教程(有挂方法)1、超多福利...
透视游戏!聚星ai辅助工具收费... 透视游戏!聚星ai辅助工具收费多少,wepoker国外版透视,AI教程(有挂秘笈)1、操作简单,无需...