How do I force my view controller to stay in portrait mode programmatically? I have created a share extension for my iOS app and I need my view to stay in portrait mode all of the time, despite the orientation of the device. The override methods below do not work:
override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientation.Portrait.rawValue)
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.Portrait
}
override func shouldAutorotate() -> Bool {
return false
}