相关文章推荐
谈吐大方的楼房  ·  ASP.NET Core ...·  1 月前    · 
乐观的卤蛋  ·  python - Type error ...·  11 月前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I declared table view as following:

self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
self.tableView.scrollEnabled = NO;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.estimatedRowHeight = 85.0;
self.tableView.rowHeight = UITableViewAutomaticDimension;

So i actually wrote - self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

Why does it still exist?

Try this: cell.separatorInset = UIEdgeInsetsMake(0.f, cell.bounds.size.width, 0.f, 0.f); in cellForRow method – alexburtnik Oct 30, 2016 at 18:40 You can also use this line on viewWillLayoutSubView method of you viewController self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; – Reinier Melian Oct 30, 2016 at 19:33

Swift 5.0 renamed it in :

self.tableView.separatorStyle = UITableViewCell.SeparatorStyle.none

Apply the line in viewDidLoad() method.

If you want to do it from nib file, set the tableView's Separator property to None

Setting separatorStyle seems to have no effect unless the table view is in the window's view hierarchy. If you have a table view on some UIView subclass, you can set it in didMoveToWindow method. – gonsee Aug 29, 2017 at 7:15

Hide tableView separators using UI

Here you select TableView 'Separator' property as 'None'.

https://i.stack.imgur.com/8KyH5.png

You can use the following code because it will not remove the line separators of the sections.:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    // Your code here //
    cell.separatorInset = UIEdgeInsetsMake(0.f, [UIScreen mainScreen].bounds.size.width, 0.f, 0.f);

My problem was when I add tableView trough code and I have separate func to show tableview and add it on mainView (slide from bottom) I needed to add this tableView.separatorStyle = .none in that func where tableView is added on mainView and constraint it.

In Swift 4.2 you can conveniently use dot notation on a tableView's separatorStyle. Like so:

tableView.separatorStyle = .none

As @gonsee point out: "Setting separatorStyle seems to have no effect unless the table view is in the window's view hierarchy. If you have a table view on some UIView subclass"

You should set the seperatorStyle in viewDidAppear if you your table in UIView.

override func viewDidAppear(_ animated: Bool) {
        self.contentView.documentTableView.separatorStyle = .none

you can archive these things in different ways

  • you can also use this one line of code in viewDidLoad()

    override func viewDidLoad() {
       super.viewDidLoad()
       tableView.tableFooterView = UIView()
            

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

  •