Advertisement
phantomon

Untitled

Oct 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.64 KB | None | 0 0
  1. override func viewDidLoad() {
  2.     super.viewDidLoad()
  3.  
  4.     // Force the device in portrait mode when the view controller gets loaded
  5.     UIDevice.currentDevice().setValue(UIInterfaceOrientation.Portrait.rawValue, forKey: "orientation")
  6. }
  7.  
  8. override func shouldAutorotate() -> Bool {
  9.     // Lock autorotate
  10.     return false
  11. }
  12.  
  13. override func supportedInterfaceOrientations() -> Int {
  14.  
  15.     // Only allow Portrait
  16.     return Int(UIInterfaceOrientationMask.Portrait.rawValue)
  17. }
  18.  
  19. override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
  20.  
  21.     // Only allow Portrait
  22.     return UIInterfaceOrientation.Portrait
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement