本文介绍了基本UIAlertController无法满足约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];
[alertController show];
此代码导致以下错误:
...[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.注意:在我的应用程序正在做的更广泛的上下文中,我别无选择,只能使用[alertController show]
Note: In the wider context of what my app is doing, I have no choice but to use [alertController show]
推荐答案您有UIWindow:0x7aebc600.height == 0.我正在猜测您的问题.
You have UIWindow:0x7aebc600.height == 0. I'm guessing that your issue.
显然,不应将窗口高度设置为0,否则添加到窗口的高度将不足.
Obviously your window height shouldn't be set to 0, otherwise whatever that you add to it won't have enough height.
此外,您还可以从这里.在页面上搜索将尝试通过打破约束来进行恢复"
Additionally you can find a very good debugging tutorial from here. On the page search for "Will attempt to recover by breaking constraint"
更多推荐
基本UIAlertController无法满足约束
发布评论