【问题标题】:UIViewAlertForUnsatisfiableConstraints when presenting popover controller on iOS8 iPad在 iOS8 iPad 上呈现弹出控制器时的 UIViewAlertForUnsatisfiableConstraints
【发布时间】:2014-12-18 06:24:45
【问题描述】:
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:@"What would you like to do?"
                                    message:@""
                             preferredStyle:UIAlertControllerStyleActionSheet];

[alert addAction:...] //left out for brevity of post

UIPopoverPresentationController *pop = [alert popoverPresentationController];
pop.sourceView = self.view;
pop.sourceRect = self.view.frame;
pop.permittedArrowDirections = UIPopoverArrowDirectionAny;

[self presentViewController:alert
                   animated:true
                 completion:^{
                 }];

中列出的 UIView 上的 UIConstraintBasedLayoutDebugging 类别中的方法也可能会有所帮助。 2014-10-22 13:33:17.966 项目 [2995:40175] 无法同时满足约束。 以下列表中的至少一个约束可能是您不想要的。试试这个:(1)查看每个约束并尝试找出您不期望的; (2) 找到添加了一个或多个不需要的约束的代码并修复它。 (注意:如果您看到不理解的 NSAutoresizingMaskLayoutConstraints,请参阅 UIView 属性 translatesAutoresizingMaskIntoConstraints 的文档) ( "=44)]>", "", "", "", “” )

将尝试通过打破约束来恢复 =44)]>

这是什么意思? >=44 是什么?

我只是想在 iPad、iOS8 上展示一个 UIAlertController

【问题讨论】:

    标签: ios8 uipopovercontroller nslayoutconstraint uialertcontroller


    【解决方案1】:

    我想简单地发表评论,但愚蠢的声誉系统不允许我这样做。

    简单地在 UIViewAlertForUnsatisfiableConstraints 上设置断点并没有帮助,因为是 UIAlertController 导致了问题,而不是用户的问题。这是 Apple 的错误,应该报告。我也明白了。在 iPhone 大小的设备上运行良好,但在 iPad 大小的设备上则失败。

    我只是通过没有将整个源视图的边界指定为 sourceRect 来让我的工作,而是在源视图中手势的位置制作了一个小矩形:

    CGPoint     loc = [ges locationInView:self.view];
    CGRect      popBox = CGRectMake(loc.x - 10, loc.y - 10, 20, 20);
    
    popoverPresentationController.sourceRect = popBox;
    

    【讨论】:

      【解决方案2】:

      您需要添加一个符号断点。 Apple 提供了一个excellent guide 说明如何执行此操作。

      打开断点导航器 cmd+7

      点击左下角的添加按钮

      选择添加符号断点...

      它说符号的地方只需输入 UIViewAlertForUnsatisfiableConstraints 您还可以将其视为任何其他断点,打开和关闭它、添加操作或记录消息。

      【讨论】:

        猜你喜欢
        • 2015-02-11
        • 1970-01-01
        • 2013-11-20
        • 2011-02-07
        • 1970-01-01
        • 2017-04-25
        • 1970-01-01
        • 2012-09-15
        • 1970-01-01
        相关资源
        最近更新 更多