Swift isLockingFocusWithCustomLensPositionSupported всегда возвращает false - PullRequest
0 голосов
/ 30 апреля 2019

Я хочу установить постоянное расстояние объектива iPhoneX. Чтобы проверить, поддерживается ли это, я проверяю свойство isLockingFocusWithCustomLensPositionSupported моего устройства, как описано в документации здесь: https://developer.apple.com/documentation/avfoundation/avcapturedevice/2361529-islockingfocuswithcustomlensposi

Метод всегда возвращает false, даже когда устройство заблокировано для настройки, что означает, что вызов метода setFocusModeLocked(lensPosition, completionHandler) всегда вызовет ошибку. Почему это так, и как правильно назвать setFocusModeLocked()?

Ниже мой подход:

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)") }

Проверено на iPhoneX, iOS 12

...