I haven’t found anything corresponding to my situation so far…
FYI, I’m developing for iOS 5, using a storyboard.
I have a tab bar controller with 2 views in it (let’s call them tab 1 and tab 2). I also have a separate landscape view, with no tab bar, which is used any time the device rotates during the application use. I use a segue launched manually in shouldAutorotateToInterfaceOrientation to switch to and from this view. I also use a NSString in the landscape view to know which tab I am coming from, to go back to correct one when I go back to portrait. So far, this works fine. I can go to and from landscape mode exactly the way I want.
My problem is :
When I launch the app, in portrait, I see the tab bar. If I go to landscape, it disappears. This is fine, that’s what I did in my storyboard. But when I go back to portrait, the tab bar does not come back ! That’s the problem.
Edit : code calling the rotation
I stopped using shouldAutorotateToInterfaceOrientation to rotate because it was conflicting with the custom segues. The problem with the tab bar was here before, so this is not the issue. I use didRotate instead.
Here is the code from FirstViewController.m (same code in SecondViewController.m, changing my segue identifier) :
-(void)didRotate:(NSNotification *)notification
{
UIInterfaceOrientation newOrientation = [[UIDevice currentDevice] orientation];
if ((newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight))
{
[self performSegueWithIdentifier: @"Page1ToLandscapeSegue" sender: self];
}
}
And from LandscapeViewController.m (previousView is a NSString, set before going to landscape, so I know which view I’m coming from) :
-(void)didRotate:(NSNotification *)notification
{
UIInterfaceOrientation newOrientation = [[UIDevice currentDevice] orientation];
if (newOrientation == UIInterfaceOrientationPortrait)
{
if ([previousView isEqualToString: @"View1"]) {
[self performSegueWithIdentifier: @"LandscapeToPage1Segue"
sender: self];
}
else if ([previousView isEqualToString: @"View2"]) {
[self performSegueWithIdentifier: @"LandscapeToPage2Segue"
sender: self];
}
}
}
Looking at your comments I’m thinking that your tab bar is disappearing because you’re seguing from a view controller that is not embedded in a tab bar controller (this being your landscape view view controller), I’d suggest the following:
1) It seems complicated to setup segues to go back to the previous view, not to mention that you’re creating more views/controllers and adding them to the stack, so discard the segues that go back to your original views.
2) Make the segues to the landscape view be modal, that way you won’t have the tab bar show up when you segue to them, if you use push it will be embedded in the tab bar controller.
3) Since the landscape view would be a modal view, simply call this method in your rotate code in the landscapes view controller:
[[self presentingViewController] dismissModalViewControllerAnimated:YES];This will push the view off the stack and go back to the view it came from.