我在我的自定义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