Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a case in iOS8, where we get NSAutoresizingMaskLayoutConstraint... #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions RZCellSizeManager/RZCellSizeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ - (void)moveConstraintsToContentView
id firstItem = cellConstraint.firstItem == self ? self.contentView : cellConstraint.firstItem;
id secondItem = cellConstraint.secondItem == self ? self.contentView : cellConstraint.secondItem;
//There is a case where we can grab the iOS7 UITableViewCellScrollView which will break, this check is for that.
if (([[firstItem superview] isEqual:self] && ![firstItem isEqual:self.contentView]) ||
// There is a case in iOS8, where we get NSAutoresizingMaskLayoutConstraints, if we have an auto layout cell
// that uses a custom view using springs and struts. This crashes the app when we try to re-add the constraint
// to the custom view, because the NSAutoresizingMaskLayoutConstraints first or second item are nil. So an additional check to see if the first and second items are nil is performed.
if (!firstItem || !secondItem ||
([[firstItem superview] isEqual:self] && ![firstItem isEqual:self.contentView]) ||
([[secondItem superview] isEqual:self] && ![secondItem isEqual:self.contentView]))
{
continue;
Expand Down Expand Up @@ -516,7 +520,7 @@ - (NSNumber *)cellHeightForObject:(id)object configuration:(RZCellSizeManagerCel
{
[configuration.cell prepareForReuse];
configuration.configurationBlock(configuration.cell, object);
[configuration.cell layoutIfNeeded];
[configuration.cell setNeedsLayout];
UIView* contentView = [configuration.cell contentView];
height = @([contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height + self.cellHeightPadding);
}
Expand Down