【问题标题】:How to fix bounds of a PopoverViewController, when presents a actionSheet (AlertController)?当呈现 actionSheet (UIAlertController) 时,如何修复 Popover ViewController 的边界?
【发布时间】:2014-08-20 07:21:20
【问题描述】:

当 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”项目中。

【问题讨论】:

    标签: ios objective-c ios8 uialertcontroller


    【解决方案1】:

    只需将preferredContentSize 用于 ViewController.m 中的 navigationController

    像这样:

    - (void)action:(id)sender
    {
        // ....
        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:historyViewController];
        navigationController.modalPresentationStyle = UIModalPresentationPopover;
        navigationController.preferredContentSize =CGSizeMake(320, 480);
        // ...
    }
    

    布局子视图控制器的任何容器视图的首选内容大小。

    参考:Apple UIViewController

    【讨论】:

    • 为什么 iOS 8 中的 action sheet 是方形的。上面修复了弹出框调整大小的问题。但在 iOS 8 操作表上的弹出窗口中,其他按钮有方角。您可以在上面的屏幕截图中看到它。似乎只发生在弹出窗口中。
    猜你喜欢
    • 2014-11-10
    • 2016-10-20
    • 1970-01-01
    • 2016-05-06
    • 2018-07-22
    • 2014-10-27
    • 2015-12-02
    • 1970-01-01
    • 2015-01-13
    相关资源
    最近更新 更多