Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- override func viewDidLoad() {
- super.viewDidLoad()
- NotificationCenter.default.addObserver(self, selector: #selector(ViewController.rotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
- }
- deinit {
- NotificationCenter.default.removeObserver(self)
- }
- func rotated() {
- if UIDevice.current.orientation.isLandscape {
- print("Landscape")
- } else {
- print("Portrait")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment