I am now pulling my hair out trying to resolve what I thought would be a simple function. I am using Xcode 6.2 to create an iOS 8 app for the iPad with 3 view controllers. My aim is once the app is launched, it locks all the views in that Landscape orientation. If it’s closed and reopened in the other Landscape orientation, all views use that. I did get this working with code below but have had to add a navigation controller because I need a Navigation Bar and it now always rotates. I have found some information that this maybe a bug in iOS8. Suggestions I have tried haven’t resolved problem as the are Object-C, this was interesting but as its not for swift I am lost.
iOS 6 shouldAutorotate: is NOT being called
Is there a simple way to accomplish this by forcing the Navigation Controller to stop rotation? Here is a snippet which used to work and the Lock screen code is in each VC:-
// Get orintation of screen if 'true' Home button on RIGHT
if (UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeLeft) {
Oriention_Number = HomeButtonRight
Screen_Orient_Vert = -1
Screen_Orient_Horiz = 1
} else {
Oriention_Number = HomeButtonLeft
Screen_Orient_Vert = 1
Screen_Orient_Horiz = -1
}
preferences.setInteger(Oriention_Number, forKey: "Oriention_Number_Prefs")
// Lock Screen
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> Int {
return Oriention_Number // Landscape HomeButtonLeft = 16 HomeButtonRight = 8
}