orientation-changes

How to detect orientation change?

丶灬走出姿态 提交于 2019-11-26 02:05:59
问题 I am using Swift and I want to be able to load a UIViewController when I rotate to landscape, can anyone point me in the right direction? I Can\'t find anything online and a little bit confused by the documentation. 回答1: Here's how I got it working: In AppDelegate.swift inside the didFinishLaunchingWithOptions function I put: NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.rotated), name: UIDevice.orientationDidChangeNotification, object: nil) and then inside the