【发布时间】:2023-04-06 11:46:01
【问题描述】:
已尽力阅读其他一些帖子,但仍然难以理解为什么这会为我的自动布局发出警告,并希望有人能提供建议。我在 xcode6 中。
问题 #1 - 对于自动布局约束,这些警告/崩溃通常可以吗?或者这是一件非常严重的事情,我应该尽最大努力解决?
问题 #2 - 这是输出。我觉得这与我在视图控制器中设置项目的纵横比有关(我有 3 个视图作为矩形,我希望它们分别是高度的 15%、60%、25% 和完全相等的宽度)。我认为告诉它保持纵横比是处理这个问题的正确方法?
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)
(
"<NSLayoutConstraint:0x7f8a66031bc0 V:[UITableView:0x7f8a65837c00(73)]>",
"<NSLayoutConstraint:0x7f8a6605c150 UITableView:0x7f8a65837c00.width == 7.78082*UITableView:0x7f8a65837c00.height>",
"<NSLayoutConstraint:0x7f8a6604e970 UICollectionView:0x7f8a65838400.leading == UIView:0x7f8a66031eb0.leadingMargin>",
"<NSLayoutConstraint:0x7f8a6604e9c0 UICollectionView:0x7f8a65838400.trailing == UIView:0x7f8a66031eb0.trailingMargin>",
"<NSLayoutConstraint:0x7f8a6604ea10 UICollectionView:0x7f8a65838400.width == UITableView:0x7f8a65837c00.width>",
"<NSLayoutConstraint:0x7f8a63c4ccf0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f8a66031eb0(320)]>"
)
非常感谢您的帮助!
【问题讨论】:
-
警告应该可以运行和测试,尽管像@hodson 建议它推迟不可避免的,最终你会想要对它们进行排序。我建议选择情节提要上的所有对象并清除约束,然后将它们一一添加,其中每个对象至少需要 4 个约束。这是一个答案的链接,它将帮助您完成添加约束的过程。 stackoverflow.com/a/25775111/2507277
-
谢谢,我最终阐明了我想要实现的目标,但认为它与原始帖子有所不同,因此发了一个新帖子:stackoverflow.com/questions/27174222/…
标签: ios ios8 autolayout xcode6