if UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation) {
print(\"landscape\")
}
if UIDeviceOrientationIsPortrait(UIDevice.currentDev
Swift 5.0:
UIDevice.current.orientation.isLandscape
UIDevice.current.orientation.isFlat
UIDevice.current.orientation.isPortrait
UIDevice.current.orientation.isValidInterfaceOrientation
isFlat: Indicating whether the specified orientation is face up or face down (The device is held parallel to the ground with the screen facing downwards or Not).
isValidInterfaceOrientation: Indicating whether the specified orientation is one of the portrait or landscape orientations.
If you have set some views to landscape form manually, so "isLandscape" value is not correct.
In this case you can use this condition:
if UIScreen.main.bounds.height < UIScreen.main.bounds.width {
print("LandScape Views")
print("Portrait Views")
}
For example I wanted to play all videos in landscape form while my app was only for portrait form, so in video views I used this condition in order to check if the view is landscape or not, independent of the phone orientation.