Reputation: 11359
Something is up with our table view cell separators on the iPhone 6 Plus. I created a blank test project with a custom cell with only one label and a 15pt constraint to the leading edge.
iPhone 5S
Label and separator are 30 px (15pt) from the leading edge. All is good.
iPhone 6 Plus
Label is 48 px (15pt) from the leading edge and the separator is 60px (20pt) from the leading edge.
If i log the tableView.separatorInset it's 15pt on the iPhone 5S and 20pt on the 6 Plus. Setting the inset to 15 on the 6 Plus manually doesn't work.
Please send help.
Upvotes: 13
Views: 2109
Reputation: 3906
Just make this option of the table to false and it will work the same on all devices, especially on iPad.
cellLayoutMarginsFollowReadableWidth = false
Upvotes: 0
Reputation: 9040
If you are using a Storyboard, select the Table View attributes inspector. Change the
Separator Inset
to
Custom
and leave the default left margin as 15
.
Upvotes: 2
Reputation: 4335
I fixed by this solution: http://qiita.com/mono0926/items/42f7a344b39e946abfe2
Get tableView.separatorInset.left
value when viewDidLayoutSubviews
called.
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
notificationLabelLeft.constant = tableView.separatorInset.left
}
Upvotes: 1
Reputation: 3343
Not a perfect solution, but it worked for me.
@IBOutlet weak var leftViewLeadingConstraint: NSLayoutConstraint!
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
switch UIScreen.mainScreen().scale {
case 2:
leftViewLeadingConstraint.constant = 7.0
case 3:
leftViewLeadingConstraint.constant = 11.0
default:
assertionFailure("Error: wrong scale value")
}
}
Upvotes: 1
Reputation: 309
Override layoutMargins method in your custom cell class.
- (UIEdgeInsets)layoutMargins
{
return UIEdgeInsetsMake(0, 15, 0, 0);
}
Upvotes: 6