В AppDelegate.swift внутри функции didFinishLaunchingWithOptions вставьте следующий код:
NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.rotated), name: UIDevice.orientationDidChangeNotification, object: nil)
, затем в AppDelegate поместите следующую функцию:
func rotated() {
if UIDeviceOrientationIsLandscape(UIDevice.current.orientation) {
print("Landscape")
}
if UIDeviceOrientationIsPortrait(UIDevice.current.orientation) {
print("Portrait")
}
}
надеюсь, что она будет работать для вас. ..:)