ios - 当呈现 actionSheet (AlertController) 时,如何修复 PopoverViewController 的边界?

标签 ios objective-c ios8 uialertcontroller

当 ViewController 通过 UIPopoverPresentationController 以 iOS 8 方式呈现 actionSheet (AlertController) 时,ViewController 会将其边界缩小到 actionSheet 的大小。

我试图做的是在弹出窗口上显示一个actionSheet,但我以iOS 8的方式做到这一点,我遇到了这种奇怪的情况。

这就是我遇到这种情况的原因”

  1. 当按下 barButtonItem 时,它会通过 UIPopoverPresentationController 弹出 ViewController。 (如图1)
  2. 当按下 ViewController 上的按钮时,它会呈现一个 actionSheet
  3. 然后 ViewController 将其大小缩小到 actionSheet 的大小。 (如图2)

这是整个项目供引用。 https://github.com/allenlinli/ALtryEverything/tree/Q435235 它位于项目“TryAlertOnPopoverOnBarButtonItemOniPad”中。

enter image description here

enter image description here

最佳答案

只需在 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 的首选内容大小。

引用:Apple UIViewController

关于ios - 当呈现 actionSheet (AlertController) 时,如何修复 PopoverViewController 的边界?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25398927/

相关文章:

javascript - 如何从 Javascript 调用 Objective-C 方法并将数据发送回 iOS 中的 Javascript?

iphone - 如何创建多个临时对象,然后使用 Core Data 只保存一个?

core-data - 如何在 Swift Int64 中使用 Core Data Integer 64?

ios - 添加和删​​除事务队列观察器 - 正确的方法?

ios - 在iOS上,有没有办法每秒刷新60帧以上?

objective-c - 我可以向 Objective-C 公开 Swift 默认参数值吗?

ios - 如何将 iOS 键盘应用程序限制为仅 iPhone 6 和 iPhone 6 Plus

ios - fetchAssetCollectionsWithType 仅检索视频

ios - 无法使用 HTTPS 连接到服务器

objective-c - 未调用未捕获的异常处理程序