0
votes

I have two views A and B. A pushes to B, and B pops back to A. In A, using "shouldAutorotateToInterfaceOrientation" I limit rotation to Portrait and PortraitUpsideDown.

In B I limit the rotation to LandscapeLeft/Right.

However, when I push to view B, regardless of the initial orientation of my device, view B also shows up Portrait until I rotate my device. From then on, it auto rotates to LandscapeLeft/Right like it should.

Everything Ive read so far talks about shouldAutorotateToInterfaceOrientation, but I have that setup correctly (at least I think I do).

How can make view B always start in Landscape?

Thanks.

2
You should reconsider the design as it makes users rotate the device after tapping buttons.Costique
@Costique I'd like to keep the app design as it is. All views but one start out in the same orientation. Kind of like the YouTube app when you play a video.wayneh

2 Answers

1
votes

You will need to use a Modal view. And have a Done button or something similar to trigger the dismissModalViewControllerAnimated.

1
votes

The easiest way to make your view controller named B always start in landscape is to present it modally, instead of pushing it to your navigation controller. This seems to be the method the YouTube app uses to rotate the interface.

B *nextVC = [[B alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:nextVC animated:YES];

If you absolutely need to push the view you can do something like this:

B *nextVC = [[B alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:nextVC animated:NO];
UIViewController *cont = [[UIViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:cont animated:NO];
[cont dismissModalViewControllerAnimated:NO];

Believe it or not it actually produces a nice effect.