我在包含UITextView的tableview中有一个单元格。 UITextview对uitableviewcell内容视图具有top,leading,trailing和bottom的限制。如果textview包含空文本,我想隐藏uitableviewcell。为此,我将单元格高度降低为0.由于textview具有相对于UITableViewCell设置的约束。隐藏包含UITextview的UITableviewcell(Autolayout)
UITableViewCell
---------------------------
| -T- |
| -L- UITextView -R- |
|_________-B-_____________|
L,T,B,R - 左,上,下,右约束
我得到的约束问题。
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.
(
"<NSLayoutConstraint:0x7fe5d58753a0 UITableViewCellContentView:0x7fe5d5874fe0.bottomMargin == UITextView:0x7fe5d399c000.bottom>",
"<NSLayoutConstraint:0x7fe5d58753f0 UITableViewCellContentView:0x7fe5d5874fe0.topMargin == UITextView:0x7fe5d399c000.top>",
"<NSLayoutConstraint:0x7fe5d5888a20 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fe5d5874fe0(0.5)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fe5d58753a0 UITableViewCellContentView:0x7fe5d5874fe0.bottomMargin == UITextView:0x7fe5d399c000.bottom>
如何隐藏单元格而没有任何自动布局问题。
你可以改变的顶部和底部的约束常数为0 –
但电池是可重复的内容。我怎样才能改变约束?你能解释更多 –
你如何设置高度为0,通过autolayout或通过heightForRow:atIndexPath? – 7vikram7