我在我的自定義UITableViewCell
中有三個UILabels
。 這可能是一些UILabels
將是空的(label.text == @""
)自動佈局UILabels
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"EventCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSString *key = [[keysArray objectAtIndex:indexPath.section] description];
UILabel *nameLabel = (UILabel *)[cell viewWithTag:100];
namelabel.text = @"Label 1";
UILabel *locationLabel = (UILabel *)[cell viewWithTag:101];
location.text = @"Label 2";
UILabel *timeLabel = (UILabel *)[cell viewWithTag:102];
timeLabel.text = @"";
return cell;
}
所有非空UILabels
垂直於電池使用自動佈局如何我中心?
這是它的外觀與三個標籤
它的外觀時UILables
一個是空
這是我多麼希望它看起來:
您是在代碼或界面構建器中構建單元嗎?爲什麼這些標籤是空的還是沒有關係? – jrturton 2013-02-09 22:14:44
在IB中。我希望我的標籤集中在容器中。這是不難做出來的,但是當其中一個標籤爲空時,我得到兩個其他標籤之間的差距,看起來不太好 – Oleg 2013-02-09 23:03:33
這可能非常困難,因爲空的UILabel可能不會聲稱寬度,但肯定是高度,所以你可能不得不寫一些代碼,'其中一個標籤是空的,刪除該標籤'。 – 11684 2013-02-10 07:36:16