我试图在iPad上创建一个简单的模式对话框,无论是小的(UIModalPresentationFormSheet)还是大的(UIModalPresentationPageSheet)设置,但无论我做什么,它们都会全屏显示(带有标题栏)。
模式UIViewController是在界面构建器中创建的,我似乎无法为其指定大小。为UIViewController中包含的UIView指定较小的大小不起作用。
我做错了什么?什么可能会影响这个问题?会不会是我设置modalPresentationStyle的时间问题?我尝试过使用和不使用UINavigationController,但都得到了相同的结果。
发布于 2011-01-12 18:51:48
我已经想通了。原来我用的是UIModalPresentationPageSheet,它总是在纵向模式中切换到全屏。因为我的模式弹出窗口不响应shouldAutorotateToInterfaceOrientation,所以它强制为纵向,这就是为什么我认为模式弹出窗口不起作用。
通过简单地向我的模式UIViewController添加一个shouldAutorotateToInterfaceOrientation处理程序,返回YES,我现在看到在横向模式下I am得到一个覆盖大部分(但不是全部)屏幕的大弹出窗口,这正是我所期望的。
发布于 2011-01-12 18:19:36
必须在父ViewController中设置modalPresentationStyle
,然后才能调用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]
https://stackoverflow.com/questions/4672314
复制