Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Something is wrong with the iPhone 6 Plus tableView.separatorInset

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 5S

iPhone 6 Plus

Label is 48 px (15pt) from the leading edge and the separator is 60px (20pt) from the leading edge.

iPhone 6 Plus

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.

like image 483
Maciej Swic Avatar asked Sep 24 '14 14:09

Maciej Swic


3 Answers

Override layoutMargins method in your custom cell class.

 - (UIEdgeInsets)layoutMargins
{
    return UIEdgeInsetsMake(0, 15, 0, 0);
}
like image 156
Vidyalaxmi Avatar answered Oct 22 '22 14:10

Vidyalaxmi


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.

like image 2
Daniel Avatar answered Oct 22 '22 15:10

Daniel


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")
    }
}
like image 1
Konstantin Cherkasov Avatar answered Oct 22 '22 15:10

Konstantin Cherkasov