presentModalViewController in landscape after port

2019-07-04 08:58发布

问题:

I have a main viewController that is in portrait mode all the time.

I want then to presentModalViewController, but it will come from the left (not from bottom of the screen) in landscape.

Is it possible?

tnx

回答1:

In your modal view controller implementation, override -shouldAutorotateToInterfaceOrientation:

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


回答2:

I came across this problem too. So i just used the modaltransitionstyle so it didn't look to iffy.

Hope this helps.

viewController.modalTransitionStyle = *modaltransitionstyle*;

[self presentModalViewController:viewController animated:YES];