模态UIViewController总是在iPad上全屏显示.为什么? [英] Modal UIViewController always coming out full screen on iPad. WHY?

查看:53
本文介绍了模态UIViewController总是在iPad上全屏显示.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在iPad上以小(UIModalPresentationFormSheet)或大(UIModalPresentationPageSheet)设置创建一个简单的模态对话框,但是无论我做什么,它们都会全屏显示(带有标题栏)./p>

模态UIViewController是在界面构建器中创建的,我似乎无法为其指定大小.为UIViewController中包含的UIView指定较小的尺寸无效.

我做错了什么?有什么可能会影响此问题?可能是我设置modalPresentationStyle的时机吗?我已经尝试过使用UINavigationController和不使用UINavigationController,但是都得到了相同的结果.

解决方案

我已经弄清楚了.事实证明,我使用的是UIModalPresentationPageSheet,它总是在纵向模式下全屏显示.因为我的模式UIViewController没有响应shouldAutorotateToInterfaceOrientation,所以它强制采用纵向方向,这就是为什么我认为模式弹出窗口不起作用的原因.

只需在我的模态UIViewController中添加一个shouldAutorotateToInterfaceOrientation处理函数,然后返回YES,我现在看到在横向模式下,我 am 会看到一个大弹出窗口,该弹出窗口覆盖了屏幕的大部分(但不是全部),这就是我一直期望的.

I am trying to create a simple modal dialog on the iPad, in either the small (UIModalPresentationFormSheet) or the larger (UIModalPresentationPageSheet) settings, but they come out full screen (with a title bar) no matter what I do.

The modal UIViewController was created in interface builder where I can't seem to specify a size for it. Specifying a smaller size for the UIView contained within the UIViewController has no effect.

What am I doing wrong? What would possibly affect this issue? Could it be the timing in which I am setting modalPresentationStyle? I have tried both using a UINavigationController and without, but am getting the same result.

解决方案

I've figured this out. Turns out I was using UIModalPresentationPageSheet, which always goes to full screen in portrait mode. Because my modal UIViewController wasn't responding to shouldAutorotateToInterfaceOrientation, it was forcing a portrait orientation, which is why I THOUGHT the modal popup wasn't working.

By simply adding a shouldAutorotateToInterfaceOrientation handler to my modal UIViewController, that returns YES, I now see that in landscape mode I am getting a large popup that covers most (but not all) of the screen, which is what I've been expecting.

这篇关于模态UIViewController总是在iPad上全屏显示.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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