Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove header and footer space from a UITableView?

Tags:

I have a UITableView in the grouped style, and only one section. However there is some blank space above and below the table view that is shown when the user scrolls too far. How can I remove this blank space?

like image 437
Christian Gossain Avatar asked Jun 17 '11 03:06

Christian Gossain


People also ask

How do you remove the blank space at the top of a grouped UITableView?

You can change the space between tableviewcells themselves by: [myTableView setSectionHeaderHeight:0]; [myTableView setSectionFooterHeight:25];

How do I remove header from Table View?

Show or hide the Header Row Click the Table Design tab > Style Options > Header Row.

How do I scroll the header along with UITableView?

If you have a single header in the table then you can use tableHeaderView as below: tableView. tableHeaderView = Header; Or if you have multiple header in table than you need to use Group table instead of plain table.


2 Answers

You can do this by altering the contentInset property that the table view inherits from UIScrollView.

self.tableView.contentInset = UIEdgeInsetsMake(-20, 0, -20, 0); 

This will make the top and bottom touch the edge.

like image 79
Deepak Danduprolu Avatar answered Sep 18 '22 13:09

Deepak Danduprolu


Add this code:

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {     return 0; }  - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {     return 0; } 
like image 26
Mohammad Anini Avatar answered Sep 21 '22 13:09

Mohammad Anini