Swift compiler error: Cannot invoke 'lockForConfiguration' with an argument list of type '(() -> ())'
Swift compiler error: Cannot invoke 'lockForConfiguration' with an argument list of type '(() -> ())'
这是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)
}
你可以试试这行代码:
device.lockForConfiguration(nil)
不应该是这样吗?
if let device = captureDevice {
device.lockForConfiguration(nil)
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()
这是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)
}
你可以试试这行代码:
device.lockForConfiguration(nil)
不应该是这样吗?
if let device = captureDevice {
device.lockForConfiguration(nil)
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()