如题,我在代码中构建cell,在UITableView的delegate中用heightForRow的delegate方法来确定cell高度。
那么如何在cell中获取这个高度来进行里面的内容的布局呢
如题,我在代码中构建cell,在UITableView的delegate中用heightForRow的delegate方法来确定cell高度。
那么如何在cell中获取这个高度来进行里面的内容的布局呢
- (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier=@"indentifier";
UITableViewCell *cell =(UITableViewCell *)([self.tableView dequeueReusableCellWithIdentifier:identifier]);
return cell.frame.size.height;
}
你可以这样获取到 cell 的实例并返回高度。
也可以直接 return 150.0;
指定高度。
2 回答1k 阅读
1 回答1.1k 阅读✓ 已解决
1 回答2.7k 阅读
1 回答1.5k 阅读
1 回答1.4k 阅读
1.7k 阅读
1 回答1.1k 阅读
如果你是用auto layout来布局的话,这样计算高度:
这里有篇文章可以看看:
http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout