问题
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?
回答1:
In ModalViewController, implement shouldAutorotateToInterfaceOrientation
the same way that it is in mainViewController (both need to agree on the orientations they support).
来源:https://stackoverflow.com/questions/4272718/modal-view-using-uimodalpresentationformsheet-appears-offscreen