UIDevice.current.orientation returns 0 when iPad is attached to external keyboard

This is the case with the iPad Pro (11-inch) and iOS 15.1 developed with Swift in Xcode version 13.1.

I don't know if it's the expected behavior or a bug. But since I'm developing a scanner using the AVFoundation Kit it's kinda weird to see the AVCaptureConnection not being in sync with the iPad's current device orientation. You're moving the iPad ,which physical orientation is in landscapeRight, up but the screen aka AVCaptureConnection is in the portrait orientation.

When using the external keyboard the current orientation is landscapeRight but not acknowledged as landscapeRight since it returns 0. As soon as I unplug the external keyboard it works as intended.

Hope it can be fixed.

Whether or not it would be an intended behavior, you can send a feedback if the current behavior does not fit for your app.

UIDevice.current.orientation returns 0 when iPad is attached to external keyboard
 
 
Q