In my iOS app I want some controllers to have only .Portrait mode and moreore I would like them to rotate in .Portrait mode when coming from a controller allowed to be in .Landscape mode. I thought that implementing the following method in these .Portrait only view controllers was the right way:
override func viewWillAppear(animated: Bool) {
self.automaticallyAdjustsScrollViewInsets = true
super.viewWillAppear(animated)
let value = UIInterfaceOrientation.Portrait.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
Anyway the result I get is not correct. For example the following is a .Portrait only UITableViewController and when viewWillAppear() is called, instead of this
I instead get the following
This happens also with UIViewController. It's like the view (or the table view) is not rotated and remains in .Landscape mode. What am I missing?

