Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: white lines in UITableView between nonexistent cells

alt text http://img179.imageshack.us/img179/2047/iphonetableview.png

I have a UITableView within a nib file. It works perfectly with 4 or more cells. When I have only 2 or 3 cells and the screen is not completely filled with cells I have these empty cells (dark gray, which is actually just the background of my TableView) at the bottom.

However, they shouldn't be there, because my numberOfSectionsInTableView and numberOfRowsInSection returns the correct values.

Any ideas?

like image 295
znq Avatar asked May 13 '10 17:05

znq


2 Answers

What you see is the default behaviour of UITableViewStylePlain. If you don't want to have "empty cells" below your real cells, move the "More" button (seen in your pic) into UITableView tableFooterView. When you don't have "More" button and still don't want "empty cells", create an empty footer:

self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

For some reason existance of tableFooterView removes "empty cells" after the real cells.

like image 152
JOM Avatar answered Oct 10 '22 04:10

JOM


I don't think they are actually cells. You are seeing the white lines because this is the default behavior for the table view. Have you tried changing the separator for the table view to none in IB?

alt text http://img.skitch.com/20100513-x5428pkyp8iaqchmkrd41h8m98.png

like image 45
Matt Long Avatar answered Oct 10 '22 04:10

Matt Long