Baub
Baub

Reputation: 5054

UITableView - Lines Between Cells

I have a UITableView that has cells of which, for this example, let's say only the top two are filled. For the rest of the cells going down the list there are still separator lines.

Is there a way to turn the lines off where there are empty cells but keep them on to separate cells that contain information?

Upvotes: 6

Views: 11921

Answers (3)

PeyloW
PeyloW

Reputation: 36762

No there is no built in support for this.

You could turn off the cells on the table view with:

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

And then draw the separator lines in your own UITableViewCell subclasses that you use for the rows.

Upvotes: 27

Rajan Maheshwari
Rajan Maheshwari

Reputation: 14571

One more way is do just write the line in viewdidLoad

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

Upvotes: 0

Ekkstein
Ekkstein

Reputation: 819

Another simple hack is to add this to the UITableViewControllers viewDidLoad Method:

    self.tableView.tableFooterView = [UIView new];

Upvotes: 1

Related Questions