Created
March 17, 2017 03:51
-
-
Save agibson73/adc79b6f06d2fc92a93a9cc75ca5ec68 to your computer and use it in GitHub Desktop.
NoRotate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In the controllers to not rotate | |
override var shouldAutorotate : Bool { | |
return false | |
} | |
override var supportedInterfaceOrientations : UIInterfaceOrientationMask { | |
return UIInterfaceOrientationMask.portrait | |
} | |
//otherwise i did not change anything. and as long as all orientations are supported if you don't set above it will rotate. | |
// on dismiss i think it reoriented but i might have ask for layout or something cannot remember. | |
// i think in the case of collectionviews i might have had to invalidate layout in viewwillappear but cannot remember | |
//navigation controller if you need it | |
import UIKit | |
class MainNavViewController: UINavigationController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
override var shouldAutorotate: Bool { | |
if !viewControllers.isEmpty{ | |
return self.topViewController!.shouldAutorotate | |
}else{ | |
return true | |
} | |
} | |
override var supportedInterfaceOrientations: UIInterfaceOrientationMask{ | |
if !viewControllers.isEmpty{ | |
return self.topViewController!.supportedInterfaceOrientations | |
}else{ | |
return self.supportedInterfaceOrientations | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment