我已尽力阅读其他一些帖子,但仍然难以理解为什么这会对我的自动布局发出警告,并希望有人可以提供建议。我在 xcode6 中。
问题 # 1 - 自动布局约束出现这些警告/崩溃通常可以吗?或者这是一件非常严重的事情,我应该尽我最大的努力去解决?
问题#2 - 这是输出。我觉得这与我在 View Controller 中设置项目的宽高比有关(我有 3 个矩形 View ,我希望它们分别是高度的 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)]>"
)
非常感谢您的帮助!
最佳答案
[[NSUserDefaults standardUserDefaults] setValue:@(NO) forKey:@"_UIConstraintBasedLayoutLogUnsatisfiable"];
此控制台警告不会造成任何问题。 在 appdelegate 中添加此代码。这将从控制台隐藏约束错误消息
关于ios - 加载 View Controller 时的自动布局警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27173302/