From b47e9cc113528e530f695e7dcd6db7225911f876 Mon Sep 17 00:00:00 2001 From: Patrick Jayet Date: Mon, 27 Oct 2014 21:29:20 +0100 Subject: [PATCH] iOS 8 bug where the content cell view appeared to be 'floating around' -> added two constraint to set its top & left --- SWTableViewCell/PodFiles/SWTableViewCell.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SWTableViewCell/PodFiles/SWTableViewCell.m b/SWTableViewCell/PodFiles/SWTableViewCell.m index b125728c..d90b0ce7 100644 --- a/SWTableViewCell/PodFiles/SWTableViewCell.m +++ b/SWTableViewCell/PodFiles/SWTableViewCell.m @@ -100,6 +100,14 @@ - (void)initializer for (UIView *subview in cellSubviews) { [_contentCellView addSubview:subview]; + if (subview.clipsToBounds) { + // iOS 8 layout bug + // clipsToBounds tells us it is a content cell view, hence we add 2 constraints for the top/left + [_contentCellView addConstraints:@[ + [NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_contentCellView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], + [NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:_contentCellView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0], + ]]; + } } // Set scroll view to perpetually have same frame as self. Specifying relative to superview doesn't work, since the latter UITableViewCellScrollView has different behaviour.