ios - iOS Autolayout:可以将约束优先级设置为 999 以使警告静音吗?
问题描述
我收到以下有关自动布局的警告。
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:0x604000285230 H:|-(64)-[UILabel:0x7fc908d51ba0] (active, names: '|':UIView:0x7fc908d52020 )>",
"<NSLayoutConstraint:0x6040002854b0 H:[UIView:0x7fc908c59f60]-(0)-| (active, names: '|':UIView:0x7fc908d52020 )>",
"<NSLayoutConstraint:0x604000285000 H:[UILabel:0x7fc908d51ba0]-(9)-[UIView:0x7fc908c59f60] (active)>",
"<NSLayoutConstraint:0x6040002855f0 UIView:0x7fc908c59f60.width == 160 (active)>",
"<NSLayoutConstraint:0x60400028a1e0 'UIView-Encapsulated-Layout-Width' UIView:0x7fc908d52020.width == 0 (active)>"
)
但是,我可以通过将尾随约束优先级设置为 999 来消除警告。这似乎消除了警告,并且布局没有任何变化。这样做可以吗?或者这会导致任何问题吗?
解决方案
这样做可以吗?或者这会导致任何问题吗?要看。可能会导致问题。
理想的方法是不破坏您修复警告的约束。问题似乎与约束有关。
"<NSLayoutConstraint:0x60400028a1e0 'UIView-Encapsulated-Layout-Width' UIView:0x7fc908d52020.width == 0 (active)>"
您的超级视图(0x7fc908d52020)强制宽度为 0。可能是您不想要的东西。
推荐阅读
- node.js - 如何在 Aws Lambda 中将 watson 助手 v2 与 Amazon 技能包连接?
- azure - ILogger.LogError 未记录异常详细信息
- mongoose - 使用数组查找文档,带或不带 $in?
- java - 如何将一些值从一个类转移到另一个类?
- asp.net-core - IdentityServer4 如何在登录到 revious url 页面后重定向而不在 IdP 注册所有路由
- javascript - 如何为 Animated.Event 上的动画值添加额外的值?
- python - 如何让 Discord Bot 播放 YouTube 音频
- r - sjPlot plot_model() 中的彩色丝带和不同线型
- asp.net-core - 在 web api (.net core) 中防止 XSS
- r - 如何在R中使用magick保存高分辨率图像?