1
votes

I am trying to add a modal view to my ipad app. All views are supposed to be in landscape mode. For style I chose form or a page sheet.

Here is the problem. When I add modal view to my view with the following code:

TempController *tmpViewController = [[TempController alloc] initWithNibName:@"TempView" bundle:nil];
tmpViewController.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentModalViewController:tmpViewController animated:YES];

My modal view is displayed in landscape mode, but the view below it is displayed in Portrait. After modal gets dismissed, view is still in potrait. If I don't attach modal to the view, the view is displayed fine, in landscape mode.

I played with statusBarOrientation and shouldAutootateToInterfaceOrientation, but still no luck. I am running xcode 4.4.1 on Mountain Lion

update: this is my shouldAutorotateToInterfaceOrientation:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
    return YES;
}
return NO;
}
1

1 Answers

0
votes

A quick note: presentModalViewController:animated: is deprecated. Apple recommend using presentViewController:animated:completion:.

To make sure I understand the question, the view controller that presents the modal view controller displays correctly in landscape mode, but then as soon as it presents the modal it changes itself to portrait mode, even though the modal view controller also displays correctly in landscape? Is this happening with an iPhone/iPod touch or iPad? What does your code look like for the shouldAutoRotateToInterfaceOrientation method of the presenting view controller?