문제

I have a tableview with a custom cell, where inside it I have a textview. For this cell I determinate its hight with the size of text and it's ok.

I work in autolayout, so for my cell I use two constraints to expand the textview for all space cell in this way

enter image description here

I can say that it work fine and my textview expand itself for all cell space.

In the view controller I have a control to check when the text (the string) is empty. When it is empty I return 0 for the cell hight.

But in this case when I return 0 and text_view is empty I have a crash but I don't know how to solve.

this is the message

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.
도움이 되었습니까?

해결책

Set TranslatesAutoresizingMaskIntoConstraints to NO of cell contentView by,

[self.contentView setTranslatesAutoresizingMaskIntoConstraints:NO];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top