我的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
。 –