When I switch UIDevice.current.orientation and print UIScreen.main.bounds.height or width I get the correct values except for when the device is upsidedown. Here the height and width values are reversed. For example, in an iPhone 8 plus simulator, the width is 414 and the height is 736. But when the simulator is upsidedown, suddenly the width is 736 and the height is 414. The code looks like this:
switch UIDevice.current.orientation {
case .landscapeLeft, .landscapeRight:
print("landscape", " width: ", UIScreen.main.bounds.width, " height: ", UIScreen.main.bounds.height)
case .portrait:
print("Portrait", " width: ", UIScreen.main.bounds.width, " height: ", UIScreen.main.bounds.height)
case .portraitUpsideDown:
print("UPSIDEDOWN", " width: ", UIScreen.main.bounds.width, " height: ", UIScreen.main.bounds.height)
default:
print("other")
}
This gives the following output:
landscape width: 736.0 height: 414.0
UPSIDEDOWN width: 736.0 height: 414.0
landscape width: 736.0 height: 414.0
Portrait width: 414.0 height: 736.0
The portrait and portraitUpsidedown should have the same height and width, but there is an inconsistancy. In portrait mode the short side should be the width so I guess there's something wrong with the upside down orientation. Or have I missunderstood how this works?