Objective c 基本UIAlertController无法满足约束

Objective c 基本UIAlertController无法满足约束,objective-c,autolayout,uialertcontroller,Objective C,Autolayout,Uialertcontroller,此代码导致以下错误: UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message

此代码导致以下错误:

 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
                                                                         message:message
                                                                  preferredStyle:UIAlertControllerStyleAlert];

[alertController show];
…[LayoutConstraints]无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。
试试这个:
(1) 看看每一个约束,试着找出你不期望的;
(2) 找到添加了不需要的约束的代码,然后修复它。
(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
"",
“=44(激活)>”,
"",
"",
=0)[\u UIAlertControllerView:0x7a26ce00'错误'](活动,名称:'|':UITransitionView:0x7ae60c70)>
)
将尝试通过打破约束进行恢复
=44(有效)>
在UIViewAlertForUnsatifiableConstraints处创建一个符号断点,以便在调试器中捕获该断点。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。

注意:在我的应用程序正在做的更广泛的上下文中,我别无选择,只能使用
[alertController show]
您有
UIWindow:0x7aebc600.height==0
。我猜你的问题

很明显,您的窗口高度不应该设置为0,否则您添加到其中的任何内容都没有足够的高度


此外,您还可以从中找到非常好的调试教程。在页面上搜索“将尝试通过打破约束进行恢复”

a
UIAlertController
实例的布局不应由您管理。。。您只需演示它,其余部分由UIKit处理AlertController的方式处理。我猜你添加了一个不应该添加任何约束的约束。我没有添加任何约束。上面的代码片段就是我在谷歌上搜索的全部内容“将尝试通过打破约束进行恢复”,我能够找到许多关于stackoverflow的问题,包括:。看一看,但我没有修改/添加/删除任何约束。我只是创建了一个警报控制器,并试图展示我经常使用的
UIAlertController
,从未见过这种情况发生。请在显示内容周围添加代码。你没有在这里展示的东西一定有问题。
...[LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. 
Try this: 
    (1) look at each constraint and try to figure out which you don't expect; 
    (2) find the code that added the unwanted constraint or constraints and fix it. 
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
"<NSAutoresizingMaskLayoutConstraint:0x7af32260 h=-&- v=-&- UITransitionView:0x7ae60c70.height == UIWindow:0x7aebc600.height   (active)>",
"<NSAutoresizingMaskLayoutConstraint:0x7af9b6f0 h=--- v=--- UIWindow:0x7aebc600.height == 0   (active)>",
"<NSLayoutConstraint:0x79f1f050 UIView:0x7ae6ec40.height >= 44   (active)>",
"<NSLayoutConstraint:0x79f1d6a0 _UIAlertControllerView:0x7a26ce00'Error'.height == UIView:0x7ae6ec40.height   (active)>",
"<NSLayoutConstraint:0x7aafb360 _UIAlertControllerView:0x7a26ce00'Error'.centerY == UITransitionView:0x7ae60c70.centerY   (active)>",
"<NSLayoutConstraint:0x7afb81e0 V:|-(>=0)-[_UIAlertControllerView:0x7a26ce00'Error']   (active, names: '|':UITransitionView:0x7ae60c70 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x79f1f050 UIView:0x7ae6ec40.height >= 44   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to     catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView  listed in <UIKit/UIView.h> may also be helpful.