2

I have searched everywhere but cannot find answer to this question.

In my UITableView's cells, there is empty space on the left side. How do I get rid of it?

I'm using swift-4 IOS-11, xCode- Version 9.0 beta 6

As shown in this picture, I can not remove the left margin.

I tried these but not:

1-> cell.imageView?.contentMode = .scaleToFill

2-> tableView.layoutMargins = UIEdgeInsets.zero

tableView.separatorInset = UIEdgeInsets.zero

3->cell.layoutMargins = UIEdgeInsets.zero

4->self.tableView.contentInset = UIEdgeInsetsMake(0, -15, 0, 0);

Please Help me :/

Rahmican
  • 123
  • 1
  • 6
  • Show the code that you have used. – PGDev Sep 14 '17 at 12:51
  • I am facing the same issue but currently (temporary fix) modified the leading constraint of cell's -> contentView's -> subview's (in your case image view) to superview's leading instead of superview's leading margin. Same done for trailing. You can also edit leading and trailing constraint and uncheck Relative to Margin check by Clicking on Superview Leading Margin & Superview Trailing Margin. – Yash Vyas Sep 27 '17 at 19:15

1 Answers1

0

Create a subclass of UITableViewCell.

Inside it set the method:

- (void)setFrame:(CGRect)frame
{
    frame.origin.x = 0;
    //More frame stuff if you want

    [super setFrame:frame];
}

Then use that subclass for cells in your UITableView.

The_Falcon
  • 287
  • 1
  • 2
  • 10