Xetius
Xetius

Reputation: 46784

Multi Column header for a UITableView with Multiple Columns

I have created a UITableView with multiple columns to display a Football League Table. Now what I really need is a header to label each column which will ideally sit at the top of the table view. How would I do this?

Upvotes: 4

Views: 7782

Answers (3)

Sebastian Celis
Sebastian Celis

Reputation: 12195

Instead of setting it as the header for your first UITableView section, it would make more sense in your situation to set it as the header to your entire table. This can be done with the tableHeaderView property of UITableView. For example:

UIView *myHeaderView = ...
[myTableView setTableHeaderView:myHeaderView]; 

Upvotes: 8

François P.
François P.

Reputation: 5166

You could create a custom UIView and set it as the first section header of your UITableView. Return it in your UITableViewDelegate's tableView:viewForHeaderInSection: method. You simply need to design it so that it aligns with the "columns" inside your custom cells.

Upvotes: 7

jpm
jpm

Reputation: 16702

This is sort of a weird interface for an iPhone app, assuming you are trying to replicate the look and feel of an HTML table, with headings, cells and etc.

If this is what you want, why not just use a UIWebView object to display your table?

Upvotes: -6

Related Questions