I’m working on a universal iPhone/iPad application. I’m using MonoTouch, but I can take answers in Obj-C (I should be able to decipher it, and MonoTouch’s UIKit is 1 to 1 for the most part).
Basically my app has 2 views: a “login” view and a “logged-in” view.
On app startup, my login view is the only subview of my main UIWindow. After logging in, I call RemoveFromSuperview on the login view and UIWindow.AddSubView to add the logged-in view. All of this works great, and orientations work also b/c I respond to ShouldAutorotateToInterfaceOrientation.
All until you logout, and the orientation starts to get all jacked up. On orientation, the app orients the status bar, but leaves my views untouched. On top of that, on the iPad my UISplitView acts very strange with my master view oriented one way and the detail view the other way.
What is the proper way to switch views in a UIWindow? I feel like the orientations should work automatically, thus I’m doing something wrong.
UPDATE:
Here is a code snippet (in C#, but you get the idea):
_loginController.View.RemoveFromSuperView();
_window.AddSubView(_loggedInController.View);
To do the reverse:
_loggedInController.View.RemoveFromSuperView();
_window.AddSubView(_loginController.View);
Fairly straightforward, right?
UPDATE 2:
I made a simple repro–even included a UISplitViewController, and it works just fine.
There must be something specific in my app that is causing this strange behavior.
In my new project, the issue randomly started occurring (not sure what I changed to make it happen). So there must be something in my UI layout causing it.
I took a suggestion from a commenter, and took a look at modal views.
The following works great:
No strange orientation problems happen now.
This also give mes the benefit of a nice sliding transition without adding any code to do it.