Pascal Bayer
Pascal Bayer

Reputation: 2613

problem with presentModalViewController

If my iPad is in Landscape mode and presentModalViewController is called the view automatically turns into portrait mode. Any solutions?

UIViewController * start = [[UIViewController alloc]initWithNibName:@"SecondView" bundle:nil];
start.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
start.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:start animated:YES];

In SecondView I've already added:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}

Upvotes: 5

Views: 4890

Answers (3)

dinosaur
dinosaur

Reputation: 648

your UIViewController 'start' must override to let it appear in right orientation.

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

I got this problam just now. And I solve it by this way. Hope this can help you too.

Upvotes: 1

Lee Whitney III
Lee Whitney III

Reputation: 10968

The problem is your sample code is creating UIViewController instead of your actual derived class. In other words instead you should be creating your controller like this:

SecondViewController *start = [[SecondViewController alloc]initWithNibName:@"SecondView" bundle:nil];

I'm assuming your view controller class is called "SecondViewController" because you were loading a nib by a similar name.

If you don't provide the right instance there is no way your delegate methods can be called.

Upvotes: 2

wuf810
wuf810

Reputation: 643

There must be something else going on because defining in IB doesn't work for me either. Is the original OP using a splitViewController?

Upvotes: 0

Related Questions