iOS 7 自定义 TableViewCell 中的自动布局问题
Autolayout Issues in iOS 7 in Custom TableViewCell
我在 iOS 7 中遇到了自动布局自定义 TableViewCell 的问题。单元格显示正确,但我得到了大量的调试控制台输出,例如:
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:0x7f9c1a4b8500 V:[UILabel:0x7f9c1a4b72d0]-(0)-[UILabel:0x7f9c1a4b7680]>",
"<NSLayoutConstraint:0x7f9c1a4b8550 V:[UILabel:0x7f9c1a4b7680]-(0)-[UILabel:0x7f9c1a488910]>",
"<NSLayoutConstraint:0x7f9c1a4b85c0 V:[UILabel:0x7f9c1a488910]-(NSSpace(20))-| (Names: '|':UITableViewCellContentView:0x7f9c1a4b66d0 )>",
"<NSLayoutConstraint:0x7f9c1a4b87f0 V:|-(NSSpace(20))-[UILabel:0x7f9c1a4b6f00] (Names: '|':UITableViewCellContentView:0x7f9c1a4b66d0 )>",
"<NSLayoutConstraint:0x7f9c1a4b8840 V:[UILabel:0x7f9c1a4b6f00]-(NSSpace(8))-[UILabel:0x7f9c1a4b72d0]>",
"<NSAutoresizingMaskLayoutConstraint:0x7f9c1a4a70e0 h=--& v=--& V:[UITableViewCellContentView:0x7f9c1a4b66d0(44)]>"
)
我只在 iOS 7 中获得此输出,并且我在跨多个视图控制器的所有自定义 table 视图单元中看到它。我已按照 post:(Using Auto Layout in UITableView for dynamic cell layouts & variable row heights) 中的所有步骤进行操作。我尝试调整这些单元格中内容视图的 AutoresizingMask,但它并没有阻止这些错误的出现。我将不胜感激关于修复这些错误的一些建议。谢谢!
这意味着你有冲突的约束,它正在选择满足一个,因为它们不能全部满足。
通常这意味着您要么:
1)您知道的约束不会同时满足,例如最小尺寸或偏移量与百分比或比率相结合。在这种情况下,你需要做的就是降低你想先打破的那个的优先级。
或者,2) 重复约束措辞不同(垂直居中,但也尾随 space,等等)这个对我来说很难远程诊断,所以发布约束很重要。
如果特定约束对您来说不是那么重要(也就是您没有花那么长时间添加它们),那么将它们全部删除,添加建议,然后从那里开始工作是一个非常有效的起点。
最后一个,
"NSAutoresizingMaskLayoutConstraint:0x7f9c1a4a70e0 h=--& v=--& V:[UITableViewCellContentView:0x7f9c1a4b66d0(44)]"
可能表明在 tableviewcell 中,translatesAutoresizingMaskIntoConstraints 属性 设置为 YES。如果是这种情况,请尝试将其设置为 NO 以避免约束与自动约束之间的冲突。
我在 iOS 7 中遇到了自动布局自定义 TableViewCell 的问题。单元格显示正确,但我得到了大量的调试控制台输出,例如:
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:0x7f9c1a4b8500 V:[UILabel:0x7f9c1a4b72d0]-(0)-[UILabel:0x7f9c1a4b7680]>",
"<NSLayoutConstraint:0x7f9c1a4b8550 V:[UILabel:0x7f9c1a4b7680]-(0)-[UILabel:0x7f9c1a488910]>",
"<NSLayoutConstraint:0x7f9c1a4b85c0 V:[UILabel:0x7f9c1a488910]-(NSSpace(20))-| (Names: '|':UITableViewCellContentView:0x7f9c1a4b66d0 )>",
"<NSLayoutConstraint:0x7f9c1a4b87f0 V:|-(NSSpace(20))-[UILabel:0x7f9c1a4b6f00] (Names: '|':UITableViewCellContentView:0x7f9c1a4b66d0 )>",
"<NSLayoutConstraint:0x7f9c1a4b8840 V:[UILabel:0x7f9c1a4b6f00]-(NSSpace(8))-[UILabel:0x7f9c1a4b72d0]>",
"<NSAutoresizingMaskLayoutConstraint:0x7f9c1a4a70e0 h=--& v=--& V:[UITableViewCellContentView:0x7f9c1a4b66d0(44)]>"
)
我只在 iOS 7 中获得此输出,并且我在跨多个视图控制器的所有自定义 table 视图单元中看到它。我已按照 post:(Using Auto Layout in UITableView for dynamic cell layouts & variable row heights) 中的所有步骤进行操作。我尝试调整这些单元格中内容视图的 AutoresizingMask,但它并没有阻止这些错误的出现。我将不胜感激关于修复这些错误的一些建议。谢谢!
这意味着你有冲突的约束,它正在选择满足一个,因为它们不能全部满足。
通常这意味着您要么: 1)您知道的约束不会同时满足,例如最小尺寸或偏移量与百分比或比率相结合。在这种情况下,你需要做的就是降低你想先打破的那个的优先级。
或者,2) 重复约束措辞不同(垂直居中,但也尾随 space,等等)这个对我来说很难远程诊断,所以发布约束很重要。
如果特定约束对您来说不是那么重要(也就是您没有花那么长时间添加它们),那么将它们全部删除,添加建议,然后从那里开始工作是一个非常有效的起点。
最后一个, "NSAutoresizingMaskLayoutConstraint:0x7f9c1a4a70e0 h=--& v=--& V:[UITableViewCellContentView:0x7f9c1a4b66d0(44)]"
可能表明在 tableviewcell 中,translatesAutoresizingMaskIntoConstraints 属性 设置为 YES。如果是这种情况,请尝试将其设置为 NO 以避免约束与自动约束之间的冲突。