gpt4 book ai didi

swift - 类型 'AVCaptureDevice' 没有成员 'defaultDevice'

转载 作者:IT王子 更新时间:2023-10-29 05:39:24 26 4
gpt4 key购买 nike

正在研究二维码阅读器。我是编程新手,所以这可能很容易解决。错误是“类型‘AVCaptureDevice’没有成员‘defaultDevice’”提前感谢您的帮助!

 //Creating session
let session = AVCaptureSession()
//Define capture device
let captureDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)

do
{
let input = try AVCaptureDeviceInput(device: captureDevice)
session.addInput(input)
}

最佳答案

您正在使用旧的 Swift 2 API。线路:

let captureDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)

应该是:

let captureDevice = AVCaptureDevice.default(for: .video)

关于swift - 类型 'AVCaptureDevice' 没有成员 'defaultDevice',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46945104/

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