ios - 自定义 TableViewCell 中 iOS 7 中的自动布局问题

标签 ios objective-c uitableview autolayout

我在 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 中获得此输出,并且我在跨多个 View Controller 的所有自定义表格 View 单元格中看到它。我已按照这篇文章中的所有步骤操作:( Using Auto Layout in UITableView for dynamic cell layouts & variable row heights )。我尝试调整这些单元格中内容 View 的 AutoresizingMask,但它并没有阻止这些错误的出现。我将不胜感激关于修复这些错误的一些建议。谢谢!

最佳答案

最后一个, “NSAutoresizingMaskLayoutConstraint:0x7f9c1a4a70e0 h=--& v=--& V:[UITableViewCellContentView:0x7f9c1a4b66d0(44)]”

可能表明在 tableviewcell 中,translatesAutoresizingMaskIntoConstraints 属性设置为 YES。如果是这种情况,请尝试将其设置为 NO 以避免您的约束与自动约束之间发生冲突。

关于ios - 自定义 TableViewCell 中 iOS 7 中的自动布局问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29017468/

相关文章:

ios - 判断一个对象是否是另一个类的子类

ios - 如何重置 Root View Controller

ios - 如何从 CocoaAsyncUDPSocket 获取地址

ios - 使用核心数据和 TableView Controller 时从 UILabel 中删除空白属性

ios - 对包括导航栏和选项卡栏的 View 进行快照

ios - 如何创建合适的 iOS CoreData 数据库模型?

ios - 使用/不使用自动引用计数创建 Cocoapods

iphone - deleteRowsAtIndexPaths 不起作用

ios - NSFetchedResultsController 未加载所有条目

ios - UITableView 在滚动表格时使用 NSTimer 重新加载数据