Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a header to UITableview programmatically

Tags:

ios

How would I add this feature programmatically? I'm not sure what I would search to find this. I know how to add the IBAction but not the code to generate this feature highlighted in the picture. Is it a custom cell or a divider?s

http://i40.tinypic.com/hthhdl.png

like image 522
Allreadyhome Avatar asked Nov 06 '13 13:11

Allreadyhome


People also ask

How do you add a header to a table view?

Header and footer views are optional, and you can customize them as much or as little as you want. To create a basic header or footer with a text label, override the tableView(_:titleForHeaderInSection:) or tableView(_:titleForFooterInSection:) method of your table's data source object.

How do I scroll the header along with UITableView?

If you want to have table view header along with section headers you have to set UITableViewStyle property to UITableViewStyleGrouped . Show activity on this post. If you have a single header in the table then you can use tableHeaderView as below: tableView.

What is Uitableviewheaderfooterview?

A reusable view that you place at the top or bottom of a table section to display additional information for that section.


1 Answers

That's just a header in the TableView, they appear on top of your section

Use this method if you want a title:

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

Or this one if you want a custom view:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

And for the height:

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
like image 156
Antonio MG Avatar answered Sep 27 '22 17:09

Antonio MG