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

时间:2014-10-22 17:37:01

标签: ios8 uipopovercontroller nslayoutconstraint uialertcontroller

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中列出的UIVonstraintBasedLayoutDebugging类别中的方法也可能有所帮助。 2014-10-22 13:33:17.966项目[2995:40175]无法同时满足约束条件。     可能至少以下列表中的一个约束是您不想要的约束。试试这个:(1)看看每个约束,并试着找出你不期望的东西; (2)找到添加了不需要的约束或约束的代码并修复它。 (注意:如果您正在查看您不了解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性的文档translatesAutoresizingMaskIntoConstraints) (     &#34 = 44)]>&#34 ;,     "&#34 ;,     "&#34 ;,     "&#34 ;,     "" )

将尝试通过违反约束来恢复 = 44)] GT;

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

我只想在iPad,iOS8上展示UIAlertController

2 个答案:

答案 0 :(得分:1)

我想简单评论一下,但愚蠢的声誉系统还是不允许我这么做。

简单地在UIViewAlertForUnsatisfiableConstraints上设置断点并不会有帮助,因为它是导致问题的UIAlertController,它不是用户的问题。这是一个Apple bug,应该报告。我也明白了。在iPhone大小的设备上运行良好,但在iPad大小的设备上失败如上所述。

我让我的工作是由而不是指定整个源视图的边界作为sourceRect,而是在源视图中的手势位置做了一个小矩形:

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

popoverPresentationController.sourceRect = popBox;

答案 1 :(得分:0)

您想要添加符号断点。 Apple提供excellent guide如何执行此操作。

打开Breakpoint Navigator cmd + 7

单击左下角的“添加”按钮

选择添加符号断点...

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

相关问题