The Human Bagel
The Human Bagel

Reputation: 7224

Remove Separator from iOS TableViewCell Xib

When creating a UITableViewCell subclass, the .xib view automatically adds a separator to the bottom of the view:

Xib default separator

My tableView sets the separatorStyle property to none; however, this gap still appears between random cells at runtime:

Simulator screenshot showing the unwanted gaps

For the life of me I cannot get this to stop showing the gap randomly or the xib to remove it. There are no attributes I can find to keep this from happening. My Google searches have turned up empty handed about this exact issue.

How do I get rid of this? Any insight is greatly appreciated

Upvotes: 2

Views: 489

Answers (4)

Gautam Shrivastav
Gautam Shrivastav

Reputation: 1238

Simply go to your tableview in xib and select the separator to none: You can refer the image in the link ! https://i.sstatic.net/noEdE.png

if you are doing it with code you can use:

tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

And for the space you are getting in right side, you can either create Custom TableView Cell, or set the width more and its x axis in negative.

Example. If your superview has width 320, set the tableview frame as:

tableview.frame = CGRectMake(-15, 20, 335, 548)

Upvotes: 0

zombie
zombie

Reputation: 5259

I think your problem is with the top or bottom constraint

check the relative to margin by double clicking on the constraint and also set the constant to 0

relative to margin

Upvotes: 1

matt
matt

Reputation: 535121

My guess is that you are adding the gap by the way you are designing your xib file cell. When I add a vertical bar view to a custom cell in a xib file, there is no gap at the bottom, and no horizontal line like the one in your screen shot:

enter image description here

Upvotes: 1

PaulPaulBoBo
PaulPaulBoBo

Reputation: 1

I think you can set this property self.tableView.separatorColor = [UIColor clearColor]; and set the layout like this:(click here

It works in my test code.(click here)

Upvotes: 0

Related Questions