UIModalPresentationFormSheet on iPad in landscape

2019-04-16 04:44发布

问题:

I created a UIViewController view from XIB with modalPresentationStyle set to UIModalPresentationFormSheet and everything works great in portrait mode. When I switch to landscape the view gets moved upperleft (it's not centered as it should be) and most part of it is clipped.

Any ideas why this is happening and how to solve it?

Thanks

回答1:

I had this problem as well. Turned out, I had the autorotate function set to Portrait for both the modal controller and the calling controller.



回答2:

In iOS 7, to solve the problem of the modal view controller to appear to the left after apparition of the keyboard (problem that I have when I present an EKEventEditViewController in UIModalPresentationFormSheet, I do :

[self presentViewController:modalViewController animated:YES completion:^{
    modalViewController.view.superview.center = self.view.center;
}];