Creating a UITableView with Taller Cells on iPhone

How can I create a UITableView with higher cells? Basically, I want to create a full-screen table with only four cells, but they should display the entire screen (1/4 each).

Assuming this is possible with a UITableView, can this be done in code as well as in Interface Builder? And also, can each cell have its own height?

- Tim

+4
source share
2 answers

For best performance, if all your rows are the same height, use the rowHeight property. It is available both from code and for Interface Builder.

If you want to configure individual row heights, you need to implement the tableView: heightForRowAtIndexPath: delegate method. It is a bit slower but more flexible.

+4
source

Just use the -tableView:heightForRowAtIndexPath: method from the UITableViewDelegate protocol to adjust the height of each cell. Something like this works great:

 - (CGFloat)tableView:(UITableView *)tv heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 70.0f; } 

Hope this helps.

+7
source

All Articles