ios - 我使用 UIAlertControllerStyleActionSheet 创建了一个 UIAlertController 然后添加了一些按钮,但提示我有布局问题
问题描述
我使用 UIAlertControllerStyleActionSheet 创建了一个 UIAlertController,然后添加了一些按钮,但提示我有布局问题。我确定我的代码没问题,但我不知道问题出在哪里,如果您知道原因,请告诉我。我将样式测试为 UIAlertControllerStyleAlert 并且没有这个问题。
我的项目只支持iphone,不支持iPad。我的开发环境:Xcode:10.2.1,iOS:12.3.1
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"cancle" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
//NSLog(@"");
}];
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"sure" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
//NSLog(@"");
}];
[alertController addAction:cancleAction];
[alertController addAction:sureAction];
[self presentViewController:alertController animated:true completion:nil];
调试输出区打印:
[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:0x282e9c5a0 UIView:0x1019286f0.width == -16>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x282e9c5a0 UIView:0x1019286f0.width == -16>
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.
解决方案
推荐阅读
- python - 如果我有“权限被拒绝”,如何在 vsc 终端中运行 python 文件?
- flutter - 如何在flutter/dart中使用multicast_dns查找IP地址?
- javascript - 替换字符串中的特定值
- python - Python Pandas:使用数据透视将行中的一些数据作为列值移动-> 意外结果
- javascript - 使用 MaterialUI 关闭输入样式
- node.js - 如何在 npx / npm 版本 7 中使用 --node-arg?
- unity3d - 有没有办法在 Unity 中制作 Line Renderer 3D?
- scikit-learn - BayesSearchCV 参数
- javascript - 从另一个动作调用动作
- node.js - 使用 express 在一页中处理 2 个表单的 post 请求