如何让UITableView行高自动调整大小到UITableViewCell的大小? [英] how to get a UITableView row height to auto-size to the size of the UITableViewCell?

查看:320
本文介绍了如何让UITableView行高自动调整大小到UITableViewCell的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让UITableView行高自动调整大小到UITableViewCell的大小?



假设我在Interface Builder中创建了UITableViewCell,并且它的高度超过了标准大小,我怎么能让UITableView行高自动调整呢? (即与在界面构建器中手动测量高度而不是以编程方式设置它相反)

解决方案

如果所有单元格都是同样,将 UITableView 上的 rowHeight 属性设置为单元格的大小。如果它们根据内容完全不同,那么您将不得不实现 -tableView:heightForRowAtIndexPath:并根据您的数据源计算每行的高度。 / p>

How to get a UITableView row height to auto-size to the size of the UITableViewCell?

So assuming I'm creating the UITableViewCell in Interface Builder, and it height is more than the standard size, how can I get the UITableView row height to autosize to it? (i.e. as opposed to manually having to measure the height in interface builder and than programmatically setting it)

解决方案

If all the cells are the same, set the rowHeight property on UITableView to the size of your cell. If they're all different based on content, you're going to have to implement -tableView:heightForRowAtIndexPath: and calculate the height for each row based on your data source.

这篇关于如何让UITableView行高自动调整大小到UITableViewCell的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆