Modal UIViewController总是在iPad上全屏显示.为什么?

ldo*_*ogy 3 iphone uiviewcontroller ios

我想创建iPad上的一个简单的模式对话框中,无论是小(UIModalPresentationFormSheet)或较大(UIModalPresentationPageSheet)设置,但他们出来全屏幕(带有标题栏),无论我做什么.

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

我究竟做错了什么?什么可能会影响这个问题?可能是我设置modalPresentationStyle的时间吗?我已尝试使用UINavigationController和没有,但我得到相同的结果.

Fel*_*lix 5

您必须调用之前modalPresentationStyle在父ViewController中进行设置presentModalViewController:animated.

myViewController = // create your new controller if needed 
myViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
myViewController.modalPresentationStyle = UIModalPresentationFormSheet;
// "self" is the parent ViewController
[self presentModalViewController:myViewController animated:YES]
Run Code Online (Sandbox Code Playgroud)