Custom UITableViewCells in iOS 8 and layoutMargin
You might want to check out the preservesSuperviewLayoutMargins property. It sound like what you are looking for.
Add the following to any cells that need to be consistently spaced with the standard cells:
- (void)layoutSubviews {
[super layoutSubviews];
if ([self.contentView respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
self.contentView.preservesSuperviewLayoutMargins = YES;
}
}
In your UITableViewCell
subclass, override layoutMarginsDidChange
and set the contentView's layoutMargins to match the cell's layoutMargins:
- (void)layoutMarginsDidChange {
contentView.layoutMargins = layoutMargins
}
i found this to be more reliable than setting preservesSuperviewLayoutMargins
to YES
.