使用UIModalPresentationFormSheet的模态视图出现在屏幕外 [英] Modal View using UIModalPresentationFormSheet appears offscreen

查看:408
本文介绍了使用UIModalPresentationFormSheet的模态视图出现在屏幕外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实现的UIViewController

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]; 

如果我在ipad处于纵向状态时启动模态,它可以正常工作.但是,当我将其固定在横向并尝试启动该模式时,该模式在ipad右上角的屏幕外出现了一半.有什么想法吗?

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?

推荐答案

在ModalViewController中,以与mainViewController中相同的方式实现shouldAutorotateToInterfaceOrientation(都需要就其支持的方向达成共识).

In ModalViewController, implement shouldAutorotateToInterfaceOrientation the same way that it is in mainViewController (both need to agree on the orientations they support).

这篇关于使用UIModalPresentationFormSheet的模态视图出现在屏幕外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆