rab*_*ace 7 uitableview ios autolayout
我使用2个多线标签制作自定义单元格,并将此标签固定到所有边.当在-tableView:heightForRowAtIndexPath:用于iOS的> = 8我返回UITableViewAutomaticDimension.但是当表视图出现时,单元格高度应该比应该大.向下滚动然后向上滚动单元格取正常高度.如何解决这个问题?
高度代码:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8) {
return UITableViewAutomaticDimension;
}
static CCTopicTableViewCell *cell;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
cell = [tableView dequeueReusableCellWithIdentifier:@"topicCellIdentifier"];
});
cell.topic = [self.topics topicAtIndexPath:indexPath];
cell.bounds = CGRectMake(0, 0, CGRectGetWidth(self.tableView.bounds), CGRectGetHeight(cell.bounds));
[cell setNeedsLayout];
[cell layoutIfNeeded];
CGSize size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
return size.height + 1;
}
Run Code Online (Sandbox Code Playgroud)
结果如下:

滚动后:

| 归档时间: |
|
| 查看次数: |
6742 次 |
| 最近记录: |