问题
I have this UITableViewController, and I wanted to change the separators' edge insets. I have managed to change the ones between cells, but the two line I have shown in the image below is not changing.
The top one is the line just below the section header view, and the other one is (I suppose) the line just above the section footer view, but I have not added or changed the latter.
Many thanks in advance
回答1:
That's what you get for using the grouped tableView
style.
Anyways... since it seems you're using -viewForHeader:
, you could easily switch to the plain tableView
style.
This can be done via the IB
:
or...
if you had instantiated the tableView
programmatically then something like:
UITableView *myTableView = [[UITableView alloc] initWithFrame:someRect
style:UITableViewStylePlain];
NOTE: Switching to the plain style will fill up any extra space with separators as if there're blank cells.
This is easily fixed by adding the following line in your -viewDidLoad
... or wherever:
[self.tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
Now...
If you complain that the section header doesn't move with the rows then, luckily since it seems you have only one section, you could make the section header, the tableView
header instead.
Basically, don't use -viewForHeaderInSection:
or -titleForHeaderInSection:
and instead have this in your -viewDidLoad
[self.tableView setTableHeaderView:theHeaderView];
But...
If you have multiple section headers and simply hate the feel of section headers floating over the cells then it seems you're out of luck and will have to stick to the grouped tableView
style.
来源:https://stackoverflow.com/questions/25649181/how-can-i-remove-or-change-the-uiedgeinset-of-these-two-uitableviewcellseparator