0

I want to know how to disable/enable rotation during view life. Is there a way to update shouldAutorotate in the view life(without reloading the view)

Thanks.

Masterfego
  • 2,648
  • 1
  • 26
  • 32

1 Answers1

1

From the Apple Docs :

  • shouldAutorotate Returns a Boolean value indicating whether the view controller's contents should auto rotate.

Declaration SWIFT func shouldAutorotate() -> Bool

OBJECTIVE-C - (BOOL)shouldAutorotate

More on this : https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/instm/UIViewController/shouldAutorotate

You should add this to the method where you decide if the user can rotate or not of your ViewController :

override func shouldAutorotate() -> Bool {
    return false
}

See also : Setting device orientation in Swift iOS

Community
  • 1
  • 1
Glenn
  • 2,808
  • 2
  • 24
  • 30
  • I agree with you but, i want by default the view rotate, and for example, if a popup appears the view can't rotate until this popup desappear. Any idea? – Masterfego Sep 16 '15 at 13:09