Hello! I have an MVC application with a single model and several views (something like skins). I want the user to be able to switch the views and I can’t get it working with interface orientation. The most simple approach looks like this:
- (void) switchToADifferentView: (UIView*) newView {
// self is a descendant of UIViewController
self.view = newView;
}
This does not work because the incoming view does not get rotated according to current orientation (until the next orientation change, test case). Is there a way to force the orientation on a view? It looks like the system is trying really hard to keep the interface controls for itself. (Or is it as simple as setting the right transform by hand?)
I figured I’d better not switch the views directly and switch controllers instead. This makes sense, as it makes the initial code simpler. But how do I switch controllers that have no “navigation relation” between them? I guess I could use presentModalViewController:
, but that seems like a hack. Same goes for navigation controller. If I exchange the controllers by hand, I get the wrong orientation again:
- (void) switchToAController: (id) incoming {
[currentController.view removeFromSuperview];
[window addSubview:incoming.view]; // does not respect current orientation
}
Now how the heck do I simply exchange the current controller for another one? Again, the controllers are something like “skins” operating above a shared model, so it really makes no sense to pretend that skin A is a “modal” dialog above skin B or that they’re a part of a navigation stack.