当 ViewController 通过 UIPopoverPresentationController 以 iOS 8 方式呈现 actionSheet (AlertController) 时,ViewController 会将其边界缩小到 actionSheet 的大小。
我试图做的是在弹出窗口上显示一个actionSheet,但我以iOS 8的方式做到这一点,我遇到了这种奇怪的情况。
这就是我遇到这种情况的原因”
- 当按下 barButtonItem 时,它会通过 UIPopoverPresentationController 弹出 ViewController。 (如图1)
- 当按下 ViewController 上的按钮时,它会呈现一个 actionSheet
- 然后 ViewController 将其大小缩小到 actionSheet 的大小。 (如图2)
这是整个项目供引用。 https://github.com/allenlinli/ALtryEverything/tree/Q435235 它位于项目“TryAlertOnPopoverOnBarButtonItemOniPad”中。
最佳答案
只需在 ViewController.m 中使用 preferredContentSize
作为 navigationController
像这样:
- (void)action:(id)sender
{
// ....
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:historyViewController];
navigationController.modalPresentationStyle = UIModalPresentationPopover;
navigationController.preferredContentSize =CGSizeMake(320, 480);
// ...
}
布局 subview Controller 的任何容器 View 的首选内容大小。
关于ios - 当呈现 actionSheet (AlertController) 时,如何修复 PopoverViewController 的边界?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25398927/