扫码关注官方订阅号
学习是最好的投资!
如果你是用auto layout来布局的话,这样计算高度:
CGSize size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]; return size.height + 1.0f; // Add 1.0f for the cell separator height
这里有篇文章可以看看:http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout
- (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;指定高度。
return 150.0;
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
如果你是用auto layout来布局的话,这样计算高度:
这里有篇文章可以看看:
http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout
你可以这样获取到 cell 的实例并返回高度。
也可以直接
return 150.0;
指定高度。