I searched high and low and I'm not sure what I came out with is the best way of dealing with this (though it seems the only one).
According to Want to use muliple nibs for different iphone interface orientations I implemented the relevant methods, and everything seems to work fine. Unfortunately I have to deal with a UINavigationController, and each page has to support both portrait and landscape modes, and reproduce the same functionalities in both modes. That means that If a user at some point decides to switch from portrait to landscape, the whole app should allow him to navigate back and forth through the pages in the mode he chose.
Apparently the bit of documentation that's missing is how to deal with this. In my views I have a number of buttons with an attached showChild method that performs the navigation. All works well in portrait mode (that is the default mode, as far as I understand). The method goes like this:
- (IBAction)showChild:(UITapGestureRecognizer *)sender {
UIView *view = [sender view];
PortraitViewController *nextPortraitViewcontroller = [[PortraitViewController alloc] initWithNibName:@"Portrait" bundle:nil];
[self.navigationController pushViewController:nextPortraitViewcontroller animated:YES];
}
But when it comes to the landscape mode I get mixed results. The showChild: method in the LandscapeViewController class is exactly the same, it builds a view starting from the PortraitViewController and pushes it to the navigation controller. It all seems to go well but when I navigate back I get the previous PortraitViewController shown, not the landscape, and also its subviews are all spread around, not where I put them.
Now the question is: since Apple doesn't really seem to care about documentation and best practices (afaik this whole mechanism is very far from ideal, and I can say this coming from a background of human-computer interaction design and programming) what's the correc--Apple way of doing this?
I set up a sample project to demonstrate how I "solved" my problem. It's probably not the only way, nor the best way, but due to documentation, or lack thereof, this is the best I came up with.
https://github.com/Morpheu5/Rotation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With