Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView grouped hide section separator

Tags:

I know this question has been asked before. But no person on the internet had a working and sufficient answer.

EDIT Obviously people don't read questions anymore, on SO. So I'm trying to clarify: I want to remove the SEPARATOR. The separator is neither the space above the section, nor the tableViewHeader or tableViewFooterView. It is only the thin line above (fully from left to right).

I have a grouped UITableView (I don't want to use a plain styled for many other reasons, take it as it is) which has multiple groups.

The first section should not have the separator line on top. Setting the separator style of the tableView is not an option, because I do need the other separators.

Setting the tableViews tableFooterView is something I often read, but it never worked.

I used the tableView with static content before and I was able to remove the separator in -[UITableViewController viewDidLoad] using this:

- (void)viewDidLoad {     [[[self headerTableCell] valueForKey:@"_topSeparatorView"] removeFromSuperView]; } 

Since I now had to change the tableView to a dynamic one, the IBOutlet property won't work anymore (obviously).

So I tried everything, -[id tableView:willDisplayCell:atIndexPath:], -[UITableViewCell initWithStyle:reuseIdentifier:, prepareForReuse, awakeFromNib] and some others.

In any case, this separator is nil. So I need a method that gets called when the complete view hierarchy of the cell is setup.

like image 412
Julian F. Weinert Avatar asked Aug 12 '15 12:08

Julian F. Weinert


People also ask

How to hide separator in UITableView swift?

To hide UITableViewCell separator completely, simply set it's colour to UIColor. clearColor(). This will make the cell separator not visible.


1 Answers

what i get from your situation you have a grouped UITableView you want the first section without separator and you want to keep the separator in the other sections so remove the separator from the whole tableview from the attributes inspector make Separator : None create custom UITableviewCell in storyboard for other sections and add View at the end of it with height 1 and width the whole screen (like default separator) it's maybe not the best idea but this will allow you to have the first section without separator

like image 68
Salma Avatar answered Oct 05 '22 05:10

Salma