Capture Image Orientation

This is regarding image orientation when captured with the device rotation lock on.'


self.photoOutput.connection(with: AVMediaType.video)?.videoOrientation = self.stillImageOrientation


I have self.stillImageOrientation listening to status bar orientation


UIApplication.shared.statusBarOrientation


However, when the user activates device rotation lock and rotates the device, captured photos get saved in the wrong orientation.


I expected this might solve the issue:

UIDevice.current.orientation


That also stops changing after the device rotation lock.


I noticed the native camera app still registers proper orientation even after the device rotation lock. Is there a way to achieve this?