我的UITableView电池,其中4个UIViews布置在垂直顺序这样,的UIView子视图自动布局问题
在每UIView的,我有两个标签这样的,
我已经为所有四个UIViews的高度约束采取了一个IBOutlet,并且当数据在该视图中不可用时,我想使视图的高度为0。问题是视图没有得到0高度,因为该视图内的UILabel的10px底部约束。
什么,我得到的是这样的,
代码,其中约束处理
NSString *toName = [self jointNameFromArray:evidence.arrTo];
if ([Utility isEmptyString:toName]) {
cell.toViewHeight.constant = 0;
}
else {
cell.lblToName.text = toName;
}
NSString *fromName = [self jointNameFromArray:evidence.arrFrom];
if ([Utility isEmptyString:fromName]) {
cell.fromViewHeight.constant = 0;
}
else {
cell.lblFromName.text = fromName;
}
NSString *ccName = [self jointNameFromArray:evidence.arrCc];
if ([Utility isEmptyString:ccName]) {
cell.ccViewHeight.constant = 0;
}
else {
cell.lblCCName.text = ccName;
}
NSString *custName = [self jointNameFromArray:evidence.arrCustodian];
if ([Utility isEmptyString:custName]) {
cell.custViewHeight.constant = 0;
}
else {
cell.lblCustName.text = custName;
}
[cell layoutIfNeeded];
你也想隐藏To标签吗? –
@TejaNandamuri当您更改约束条件时需要调用layoutIfNeeded方法时,可以使用 – Bhavesh
。 –