How can I remove or change the UIEdgeInset of these two UITableViewCellSeparators?

亡梦爱人 提交于 2019-12-11 22:43:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!