I am trying to change the orientation of a single UIViewController programmatically. The user should choose in the settings if the view will be portrait or not. The value will be saved in NSUserDefaults and in the specific ViewController the orientation should be changed. So if Portrait is on the interfaceOrientation should be on UIInterfaceorientationUpsideDown……
I used following method but it will only change the orientation when the user will turn the device to landscape/portrait… otherwise nothing will be triggered.
- (BOOL)shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation
Furthermore i tryied the next one (also with method name “setOrientation“):
[[UIDevice currentDevice] orientation: UIDeviceOrientationPortraitUpsideDown];
But again, nothing happens, there just appear errors because xcode sayes there are no methods with this name.
But ther should be another way to change it programatically…
the first method is also just a method that handles the actionListener after device position but there should be a way to call this actionListener in a direct way….
I just looked inside the UIApplication File but there is no usefull method….
You should use something like this code:
And then, change your view according to the orientation:
Hope it helps 😛