0

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 advanceenter image description here

Septronic
  • 1,156
  • 13
  • 32

1 Answers1

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:

tableView Style

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.

staticVoidMan
  • 19,275
  • 6
  • 69
  • 98
  • Hi @staticVoidMan Thanks for the answer, but if I change it to plain view, my custom UIVewCell is going to go berserk, so I was wondering if there is a way to use grouped tableview, and have the separators corrected? – Septronic Sep 03 '14 at 17:13
  • @Septronic : honestly, I have not come across any way to disable the section separators in a grouped style so I am guessing the answer is "No" but... anyways, why would your custom `UITableViewCell` go berserk? – staticVoidMan Sep 03 '14 at 17:18
  • hmm, that'll make things complicated I guess! I will have to find another route!! :) I have implemented this round section effect, similar to how grouped sections used to look like. So when I change the style to plain, everything stops working and sizes/measurements and colours change. – Septronic Sep 03 '14 at 17:32
  • @Septronic : hm... those separators are really irritating at times :/ ...anyways, best of luck :) – staticVoidMan Sep 03 '14 at 18:41
  • Lol, managed to sort those out. Got rid of the round rectangle and made a backgroundimage instead of changing the shape of the cell, not ideal but better than throwing my laptop out of the window! now I've got another problem though, do you know how to remove excess separators from the end of the table? I've got two extra separators underneath the confirm box as seen in the image. There's nothing there, as in sections or rows, yet those pesky separators are there!! I don't suppose you know why? Thanks for all your helps anyway! :) – Septronic Sep 03 '14 at 19:30
  • @Septronic : haha but erm... 2 extra separators... in grouped style?? – staticVoidMan Sep 03 '14 at 19:56
  • @staticVoicMan lol :) that was a grammatically incorrect comment :) got it all working bud. Thanks for all the help :) – Septronic Nov 10 '14 at 16:01