问题
I want to set the lens distance of my iPhoneX to a constant.
In order to check if that is supported, I check the isLockingFocusWithCustomLensPositionSupported
property of my device, as described in the documentation here: https://developer.apple.com/documentation/avfoundation/avcapturedevice/2361529-islockingfocuswithcustomlensposi
The method always returns false, even when the device is locked for configuration, which means that calling the method setFocusModeLocked(lensPosition, completionHandler)
will alway throw an error.
Why is this the case, and how to correctly call the setFocusModeLocked()
?
Below is my approach:
let device = self.deviceInput.device
do {
try device.lockForConfiguration()
if device.isFocusPointOfInterestSupported && device.isFocusModeSupported(focusMode)
{
// this return true
}
if device.isLockingFocusWithCustomLensPositionSupported
{
//this always returns false
device.setFocusModeLocked(lensPosition: focusDistance, completionHandler: nil)
}
device.unlockForConfiguration()
} catch { print("Could not lock device for configuration: \(error)") }
Tested on iPhoneX, iOS 12
来源:https://stackoverflow.com/questions/55915863/swift-islockingfocuswithcustomlenspositionsupported-always-returns-false