Search code examples
iosswiftavfoundationiphone-x

setExposureModeCustom crahes in iPhone X swift 4


I have an app, which will access Camera's Exposure mode settings for changing the Shutter Speed of the Camera with Custom values. And it's works as expected in maximum devices, except iPhone X. Below is the code which i am using,

do {
    try captureDevice.lockForConfiguration()
    captureDevice.setExposureModeCustom(duration: CMTimeMake(1,30), iso: 120, completionHandler: { (time) in
})
    captureDevice.unlockForConfiguration()
} catch {
    debugPrint(error)
}

It's crashes in above line and crash log says to check whether isExposureModeSupported.

crash log screenshot.

What is my problem is, we can check isExposureModeSupported, but if is all the iPhone X device doesn't support Custom Exposure mode? if so how can we make to support Custom Exposure Mode in iPhone X?

Or Do we need to change anything in the Camera Settings?

Can anyone please help in this?


Solution

  • iPhone x does support custom exposure, but when the builtInDualCamera device is selected all the custom settings are disabled. You just need to use another device, builtInWideAngleCamera or builtInTelephotoCamera.