在iPhone上使用更高的单元格创建UITableView [英] Creating a UITableView with Taller Cells on the iPhone
问题描述
如何创建具有较高单元格的UITableView?基本上,我想创建一个只有四个单元格的全屏表格,但是它们应该占据整个屏幕(每个单元格为1/4)。
How can I go about creating a UITableView with taller cells? Basically, I want to create a full screen table with only four cells, but they should take up the entire screen (1/4 each).
假设可以使用UITableView,可以在代码中还是在Interface Builder中完成?而且,每个单元格都可以有自己的高度吗?
Assuming this is possible using a UITableView, can it be done both in code and in Interface Builder? And also, can each cell have its own height?
-Tim
推荐答案
为了获得最佳性能,如果所有行的高度都相同,请使用rowHeight属性。
For best performance, if all your rows are the same height, use the rowHeight property. It's accessible from both code and Interface Builder.
如果要自定义行的高度,则需要实现-tableView:heightForRowAtIndexPath:委托方法。性能稍慢一些,但更灵活。
If you want to customise individual row heights, then you need to implement the - tableView:heightForRowAtIndexPath: delegate method. It's a little slower performing, but more flexible.
这篇关于在iPhone上使用更高的单元格创建UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!