Why is [UIViewController presentModalViewController:animated:] transitioning the modal view in from the left?

2.1k views Asked by At

I'm building an application that supports only Landscape orientation on the iPad under iOS 4.3, though the bug was present under iOS 4.2 as well.

Several places in the application, I am showing UIViewControllers as modal views. All of them are shown using this pattern:

viewController.modalPresentationStyle = UIModalPresentationFormSheet;
viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:viewController animated:YES];

In most places, they work as expected - the modal form sheet slides in from the bottom of the screen upward.

However, in two cases, the modal form sheet slides in from the bottom left of the screen. The form sheet slides nearly all the way to the right with the bottom of the form sheet out of view. If you focus a text field and show the onscreen keyboard, the form sheet moves to the top center of the screen where you would expect it to be.

I don't think the Simulated Metrics of the XIBs affect their behaviour, but I have set the orientation for all of them (both the calling UIViewController self and the modal view controller viewController) to Landscape.

Any ideas why these two modal form sheets are behaving differently from the others?

2

There are 2 answers

0
Jesse Gumpo On

Make sure if you have a viewController embedded in a NavigationController that the navController shouldAutotorate is also set to landscape

0
Sandhya Shettigar On

I think here you dint return landscape orientation in shouldAutorotate function so use this code if you wan view as landscape left/right:

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

Try this it may help you..