gpt4 book ai didi

autolayout - UIAlertView 给出约束错误

转载 作者:行者123 更新时间:2023-12-01 16:29:48 27 4
gpt4 key购买 nike

我有以下代码,当我的应用程序出现问题时,会显示包含不同消息的警报。该代码多年来一直运行良好,并且存在于我在 App Store 上的大多数应用程序中。

我正在制作一个新应用程序,只是添加了此代码,但是我在控制台中看到下面的错误消息,我无法摆脱它。

约束消息是指警报宽度,但我没有设置约束,也无法调整任何约束来消除警告。

有人可以告诉我出了什么问题吗?

谢谢

-(void)errorMessage:(id)sender
{

UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Information",)
message:displaymessage
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *firstAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK",)
style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self dismissViewControllerAnimated:NO completion:nil];
}];

[alert addAction:firstAction];
[self presentViewController:alert animated:YES completion:nil];
}

2019-04-18 09:17:54.785207+0100 TestInputView5[1380:28232] [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.
(
"<NSLayoutConstraint:0x600001e15b30 UIView:0x7fe60c6104e0.width == - 16 (active)>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600001e15b30 UIView:0x7fe60c6104e0.width == - 16 (active)>

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

最佳答案

我在俄罗斯论坛上找到了解决方案。它看起来像魔法,但确实有效。你需要做两件事:1)向警报添加空 View 2)不带动画显示

alert.view.addSubview(UIView()) // I can't explain it, but it works!

self.present(alert, animated: false)

论坛致谢:https://quares.ru/?id=33972

这篇文章是机器翻译的,所以我想应该有英文原文(我找不到)

关于autolayout - UIAlertView 给出约束错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55741976/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com