gpt4 book ai didi

ios - Swift 编译器错误 : Cannot invoke 'lockForConfiguration' with an argument list of type '(() -> ())'

转载 作者:搜寻专家 更新时间:2023-10-30 21:53:21 27 4
gpt4 key购买 nike

这是 Swift 2。我似乎找不到任何相关信息。我收到错误

Cannot invoke 'lockForConfiguration' with an argument list of type '(() -> ())'

这里是第二行。

if let device = captureDevice {
device.lockForConfiguration() {
device.videoZoomFactor = 1.0 + CGFloat(ratioValue)
device.unlockForConfiguration()
}
print(ratioValue)
}

最佳答案

在 Swift 2 中,lockForConfiguration 方法不接受任何参数,而是可以抛出一个 NSError。您应该将其包装在 do-try-catch 语句中。

do {
try device.lockForConfiguration()
} catch {
// handle error
return
}

// When this point is reached, we can be sure that the locking succeeded
device.videoZoomFactor = 1.0 + CGFloat(ratioValue)
device.unlockForConfiguration()

关于ios - Swift 编译器错误 : Cannot invoke 'lockForConfiguration' with an argument list of type '(() -> ())' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32544720/

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