I\'m defining custom UITableViewCells in a storyboard. I\'m also using some of the built in standard style cells. I need to set up constraints so that my
What worked for me was adding these 2 lines to my custom UITableViewCell implementation:
self.preservesSuperviewLayoutMargins = YES;
self.contentView.preservesSuperviewLayoutMargins = YES;
// ... add test view to content view...
Then I used Auto Layout with the default spacing:
[self.contentView addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|-[testView]-|" options:0 metrics:nil
views:@{@"testView":testLabel}]];
[self.contentView addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:|-[testView]-|" options:0 metrics:nil
views:@{@"testView":testLabel}]];