在iOS8 iPad上呈现弹出控制器时,出现UIViewAlertForUnsatisfiableConstraints错误。

3
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 Project[2995:40175] 无法同时满足约束条件。以下约束条件列表中至少有一个是不需要的,请尝试:(1)查看每个约束条件并尝试找出您不需要的约束条件;(2)查找添加不需要的约束条件的代码并进行修复。(注意:如果您看到了您不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性translatesAutoresizingMaskIntoConstraints的文档)

( "=44)]>", "", "", "", "" )

将尝试通过破坏约束条件=44]来恢复。

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

我只是想在iPad上的iOS8上显示一个UIAlertController。

2个回答

1
我想简单地评论,但是愚蠢的声誉系统还不允许我这样做。
仅在UIViewAlertForUnsatisfiableConstraints上设置断点是无济于事的,因为UIAlertController才是问题所在,而不是用户的问题。这是一个苹果的错误,应该报告。我也遇到了这个问题。在iPhone大小的设备上运行良好,但在iPad大小的设备上会出现上述问题。
我刚刚通过在源视图中手势位置创建一个小矩形,而不是指定整个源视图的边界作为源矩形,使它能够正常工作:
CGPoint     loc = [ges locationInView:self.view];
CGRect      popBox = CGRectMake(loc.x - 10, loc.y - 10, 20, 20);

popoverPresentationController.sourceRect = popBox;

0

您需要添加一个符号断点。苹果公司提供了一篇优秀指南,介绍如何执行此操作。

打开断点导航器 cmd+7

点击左下角的添加按钮

选择添加符号断点...

在“符号”处只需键入UIViewAlertForUnsatisfiableConstraints 您也可以像其他断点一样对其进行操作,打开和关闭它,添加操作或日志消息。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接