Modal view using UIModalPresentationFormSheet displayed on screen

I have a UIViewController that implements

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

Then I try to derive a modal on top of this view:

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

If I run modal and ipad in portrait, it works fine. But when I hold it in the landscape and try to launch the modal, the modal appears half on the screen in the upper right corner of the ipad. Any ideas?

+3
source share
1 answer

In the ModalViewController, implement the shouldAutorotateToInterfaceOrientationsame as in the mainViewController (both must coordinate the orientations that they support).

+4
source

Source: https://habr.com/ru/post/1776800/


All Articles