Proper relayout if size changes

This commit is contained in:
Michael Schneider
2016-11-14 10:10:47 -08:00
parent 0eb882bae5
commit dcc54c0d36
4 changed files with 25 additions and 2 deletions

View File

@@ -120,9 +120,8 @@ static NSMutableSet *__cellClassesForVisibilityNotifications = nil; // See +init
- (void)didInvalidateSize
{
// TODO: coalesc: Ask the UITableView for the proper constrained size it can layout
CGSize oldSize = self.calculatedSize;
CGSize newSize = [self sizeThatFits:CGSizeMake(CGRectGetWidth(self.bounds), CGFLOAT_MAX)];
CGSize newSize = [self layoutThatFits:[self constrainedSize]].size;
if (CGSizeEqualToSize(oldSize, newSize) == NO) {
self.frame = {self.frame.origin, newSize};
@@ -174,6 +173,14 @@ static NSMutableSet *__cellClassesForVisibilityNotifications = nil; // See +init
}
}
- (ASSizeRange)constrainedSize
{
if (_interactionDelegate != nil) {
return [_interactionDelegate constrainedSizeForNode:self];
}
return ASSizeRangeMake(CGSizeZero, CGSizeMake(CGRectGetWidth(self.bounds), CGFLOAT_MAX));
}
- (void)setSelected:(BOOL)selected
{
if (_selected != selected) {