I am creating a simple utility app based on the xcode Utility App template. I want to restrict the FlipsideViewController orientation to only the orientation that the device was in when the FlipsideViewController was called. What is the easiest way to do this? I’ve tried doing it several different ways but so far all of them have failed. Thanks…
Share
First, get the current orientation:
Then, disallow anything else:
ADD: I did some more testing and there are significant behavioral differences between the simulator and the device with respect to startup orientation. The device appears to behave correctly, but the simulator does not. It appears that if you put the simulator in landscape mode, when the app is started the simulator doesn’t remember to send the app messages to tell the app that it needs to rotate. The simulator doesn’t realize that it is in landscape. Below are traces from sim and device.
Device:
[TiAeManageSearchesVC.shouldAutorotate] intfOrient=1
[TiAeManageSearchesVC.shouldAutorotate] intfOrient=1
[TiAeManageSearchesVC.shouldAutorotate] intfOrient=1
[TiAeManageSearchesVC.shouldAutorotate] intfOrient=4
[TiAeManageSearchesVC.shouldAutorotate] intfOrient=4
[TiAeManageSearchesVC.viewDidAppear] self.intfOrient=4
Simulator:
[TiAeManageSearchesVC.shouldAutorotate] intfOrient=1
[TiAeManageSearchesVC.shouldAutorotate] intfOrient=1
[TiAeManageSearchesVC.shouldAutorotate] intfOrient=1
[TiAeManageSearchesVC.viewDidAppear] self.intfOrient=1
So the above code will work with the exception of the noted log message. I am adding the following lines to improve the solution on physical devices. This will eliminate the error message in the log.
Otherwise, I think the problem is with the simulator. If you are trying to test against the first view when the app loads on the simulator, you will have these problems. I have tested subsequent views and they work correctly if you do the following: