Swift isLockingFocusWithCustomLensPositionSupported always returns false

偶尔善良 提交于 2020-01-23 17:01:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!