I think I found a bug in the UIDevice.orientation variable.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
if UIDevice.current.orientation.isPortrait{
print("Orientation is Portrait")
}
else{
print("Orientation is Landscape")
}
}
Everything works fine if I hold the device(Iphone 5) in my hand, but if it lies flat on the table I get "Orientation is Landscape" even if everything is shown in Portrait and the device itself is not rotated. Is there any possible way to do something against this?
// Edit: This test also fails within button-actions.
There are more orientations besides portrait and landscape. You are checking for portrait and assuming everything else is landscape. It is not. In this case, the actual orientation is likely “face up”.
There is a third option UIDevice.current.orientation.isFlat beside portrait and landscape and You are checking only for portrait
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With