0
votes
Hello, thanks for reading.

I 've tried to remove these separators since a while, it's horrible I can't delete them. I have tried a lot of answers in stackoverflow but no one was helpfull :/

Here is the problem :

UITableView Separator

I can't remove these white spaces between cells :s.

I've tried :

  • Change background color to same grey than cell,but it does not works
  • Checking cell size
  • Set separatorStyle to UITableViewCellSeparatorStyle.None
  • Returning the good height with tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
  • Disabling separator in main storyboard

... I really don't understand how to remove these white space ...

Sorry for my english,

Thanks

I'm adding this. Now you can check my settings : (And you can see separators are disabled)

Settings uitableview

9
It looks like it's not a separator but simply space between cells. Do you have any headers/footers? Try setting header background colour to cell background colour and see if the white space is still there. - haluzak
for me the UITableViewCellSeparatorStyle.None solution is working perfect having de code in the - (id)initWithStyle:(UITableViewStyle)style function. I don't know if there is a way for you to send me de project!! it would be much easier to help you in this way :) - abanet
check,reduce the height of cell and add tableview background color. then attached the screen here. are you using custom cell? - HariKrishnan.P
My tableView have a grey background-color. I'm using custom cell, yes, but I have set the good height :s - Samuel Louart
Seems like every other cell is a different size. It almost seems intentional. Is this your code that generates this? Could you post your cellForIndexPath function? And perhaps any setup function you have in your cell if there is any custom cells in the table? - Moriya

9 Answers

2
votes

you just need to change this in the Attribute inspector:

enter image description here

0
votes

Try this tableView method:

override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat 
{
    return 0.00001
}
0
votes

Try this hope it will be help full to you.

Objective C :

-(CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.1f;
}
-(UIView*)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section
{
    return [[UIView alloc] initWithFrame:CGRectZero] ;
}

Swift :

override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    return UIView(frame: CGRectZero)
  }

  override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
    return 0.1f
  }
0
votes

set the tableviewcell separator none likewise the image http://imgur.com/MbVA7pM

0
votes

Try this out:

func tableView(tableView: UITableView!, willDisplayCell cell: UITableViewCell!, forRowAtIndexPath indexPath: NSIndexPath!) {
    // Remove seperator inset
    if cell.respondsToSelector("setSeparatorInset:") {
        cell.separatorInset = UIEdgeInsetsZero
    }

    // Prevent the cell from inheriting the Table View's margin settings
    if cell.respondsToSelector("setPreservesSuperviewLayoutMargins:") {
        cell.preservesSuperviewLayoutMargins = false
    }

   // Explictly set your cell's layout margins
   if cell.respondsToSelector("setLayoutMargins:") {
       cell.layoutMargins = UIEdgeInsetsZero
   }
}
0
votes

In swift hiding the table view separator

func tableView(tableView: UITableView!, willDisplayCell cell: UITableViewCell!, forRowAtIndexPath indexPath: NSIndexPath!) 
{
   cell.backgroundColor = UIColor.clearColor()
}
0
votes

Ok I'm sorry, the problem was on my code, so you could not answer me ...

It was in my function : tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

Somewhere I wanted a border on my cell, so I have write:

var layer: CALayer = cell.layer
        layer.borderColor = UIColor.rgbaColor(red: 288, green: 83, blue: 88, alpha: 1).CGColor
        layer.borderWidth = 2

But this code didn't work because red:288 should be red:188, so I had a white border instead of an error, and I did not noticed ... Sorry for this, thanks a lot for your help :)

0
votes

Just set the footer view to empty view:

self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

so separator will disappear for empty cells (you still keep separator for normal cells).

0
votes

In objective c

[self.tableView setSeparatorColor:[UIColor myColor]];

In Swift

tableView.separatorColor = UIColor.clear