3

I have a UIViewController that implements

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

Then, I try to popup a modal on top of that view:

ModalViewController *modalViewController = [[ModalViewController alloc] init];
modalViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
modalViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[mainViewController presentModalViewController:modalViewController animated:YES]; 

If I launch the modal while the ipad is in portrait, it works fine. But when I'm holding it in landscape and try to launch the modal, the modal appears half offscreen to the upper right of the ipad. Any ideas?

Julie
  • 195
  • 1
  • 7

1 Answers1

4

In ModalViewController, implement shouldAutorotateToInterfaceOrientation the same way that it is in mainViewController (both need to agree on the orientations they support).

  • 1
    What about a view controller that doesn't appear centered when I present it UIModalPresentationFormSheet? Do you have a clue why? – Carlos Ricardo Jan 25 '12 at 17:03
  • Sorry, no. Suggest you ask a new Question with code and other details. –  Jan 25 '12 at 17:15
  • 1
    So what did I do, implemented that same ViewController but as a TableView, and it expands on FormSheet and is now centered √ :) – Carlos Ricardo Jan 26 '12 at 11:06