if UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation) {
print("landscape")
}
if UIDeviceOrientationIsPortrait(UIDevice.currentDevice().orientation){
print("portrait")
}
How can I check if it's landscape left or right?
Swift 3+
This works on Swift 3 & 4
UIDeviceOrientation will return a value for that:
SWIFT 4.2
There is one thing that destroy all this answers - it's iOS9 iPad multitasking.
To do right cell size for UICollectionView I do next :
and inside viewWillTransition next:
because it works faster than without.
you can do something like,