Joe
Joe

Reputation: 3961

Removing undesired left indent on UITableViewCell

I have a Table View within my main UIViewController that has one non-editable prototype cell. I am trying to remove the left indent from the table view cell. No matter what method I use, the indent does not go away.

Here is what I have tried:

I also tried the following in code:

myTable.layoutMargins = UIEdgeInsets.zero
myTable.separatorInset = UIEdgeInsets.zero

And this inside of cellForRowAt:indexPath

cell.indentationLevel = 0
cell.indentationWidth = 0
cell.layoutMargins = UIEdgeInsets.zero
return cell

Here's a screenshot of what's occurring:

Undesired left indent

I need all of the "Hello's" to left-align with the red section header text.

How can I remove the left-indent of the content?

Thanks.

Upvotes: 0

Views: 521

Answers (3)

kai
kai

Reputation: 330

I'm sure that layoutMargins is the reason of indent on UITableViewCell. But I think you can't change layoutMargins. I almost don't use textLabel of UITableViewCell. You can refer to Setting layoutMargins of UIView doesn't work.

Upvotes: 1

Jackspicer
Jackspicer

Reputation: 1847

Have you tried using a custom cell with a label and at the required distance from the left edge?

Upvotes: 1

iDeveloper
iDeveloper

Reputation: 2444

Try this -

helloLabel.textAlignment = .Left
cell.addSubview(helloLabel)

Upvotes: 0

Related Questions