Ok - this has been driving me mad for hours. I've Googled and I have tried numerous approaches but I still cannot get to the bottom of this.
I have an application when all of the View Controllers need to be portrait only - except one, which can be portrait or landscape. Simple surely.
Well, I have subclassed the
UINavigationController and overridden
GetSupportedInterfaceOrientations to return the corresponding value from it's
TopViewController. Each ViewController has also overridden the
GetSupportedInterfaceOrientations method to return the appropriate
That all works as I navigate through the application the portrait only views stay in portrait and the portrait/landscape view can indeed be rotated and behaves as expected.
If I rotate the device while on the 'mixed mode' view and then click on a button which takes be back on step (calling
NavigationController.PopViewController) then the resulting view spins back to a portrait orientation - exactly what I expect and indeed what I want to happen.
But, if I click a button which takes me 'Home' (calling
NavigationController.PopToRootController) then the resulting view remains in landscape orientation. If I rotate the device back to portrait and the view follows suit and once there is it locked in place - further rotation does nothing.
I have tried all manner of options of
PerformSelector with no joy (far from it in fact).
I have attached a simple project to demonstrate this. It contains a subclassed UINavigationController and three UIViewControllers , A, B and C.
A and B are portrait only while C allows Landscape. Click the buttons to navigate to ViewController C and then rotate the device. If you tap the 'Go to View Controller B' button the view will snap back to portrait, but if you tap the 'Go to View Controller A' button it will not.
Can someone please restore my sanity - what am I missing here?