[英]iOS: Constraint in a custom tableview cell
我有一个带有自定义单元格的tableview,在其中有一个textview。 对于此单元格,我用文本大小确定其高度,这没关系。
我在自动布局中工作,因此对于我的单元格,我使用两个约束以这种方式扩展所有空间单元格的textview
我可以说它可以正常工作,并且我的textview可以针对所有单元格空间进行扩展。
在视图控制器中,我有一个控件来检查文本(字符串)何时为空。 当它为空时,我为单元格高度返回0。
但是在这种情况下,当我返回0且text_view为空时,我崩溃了,但我不知道如何解决。
这是消息
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:0x1704864a0 V:|-(25)-[UITextView:0x15454d960] (Names: '|':UITableViewCellContentView:0x178179680 )>",
"<NSLayoutConstraint:0x1704864f0 V:[UITextView:0x15454d960]-(23)-| (Names: '|':UITableViewCellContentView:0x178179680 )>",
"<NSAutoresizingMaskLayoutConstraint:0x17889a220 h=--& v=--& V:[UITableViewCellContentView:0x178179680(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1704864f0 V:[UITextView:0x15454d960]-(23)-| (Names: '|':UITableViewCellContentView:0x178179680 )>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
将单元格contentView的TranslatesAutoresizingMaskIntoConstraints
设置为NO
,
[self.contentView setTranslatesAutoresizingMaskIntoConstraints:NO];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.