[ASTableView] Generate a new cell layout if existing ones are invalid (#942)

This commit is contained in:
Huy Nguyen
2018-05-28 18:26:01 +03:00
committed by GitHub
parent 60e3f97241
commit 8a4bb6cf06
3 changed files with 16 additions and 4 deletions

View File

@@ -56,6 +56,7 @@
- [ASDisplayNode] Fix an issue that causes a node to sometimes return an outdated calculated size or size range. [Huy Nguyen](https://github.com/nguyenhuy) [#808](https://github.com/TextureGroup/Texture/pull/808)
- Add an experimental deallocation queue implementation that's more efficient. [Adlai Holler](https://github.com/Adlai-Holler)
- Standardize property declaration style. [Adlai Holler](https://github.com/Adlai-Holler)
- [ASTableView] Fix an issue that causes table view to use one of a cell's invalid layouts instead of generating a new one. [Huy Nguyen](https://github.com/nguyenhuy) [#942](https://github.com/TextureGroup/Texture/pull/942)
## 2.6
- [Xcode 9] Updated to require Xcode 9 (to fix warnings) [Garrett Moon](https://github.com/garrettmoon)

View File

@@ -664,11 +664,13 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
- (CGSize)sizeForElement:(ASCollectionElement *)element
{
ASDisplayNodeAssertMainThread();
ASCellNode *node = element.node;
if (element == nil || node == nil) {
if (element == nil) {
return CGSizeZero;
}
ASCellNode *node = element.node;
ASDisplayNodeAssertNotNil(node, @"Node must not be nil!");
BOOL useUIKitCell = node.shouldUseUIKitCell;
if (useUIKitCell) {
ASWrapperCellNode *wrapperNode = (ASWrapperCellNode *)node;

View File

@@ -919,8 +919,14 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
ASCellNode *node = [_dataController.visibleMap elementForItemAtIndexPath:indexPath].node;
CGFloat height = node.calculatedSize.height;
CGFloat height = 0.0;
ASCollectionElement *element = [_dataController.visibleMap elementForItemAtIndexPath:indexPath];
if (element != nil) {
ASCellNode *node = element.node;
ASDisplayNodeAssertNotNil(node, @"Node must not be nil!");
height = [node layoutThatFits:element.constrainedSize].size.height;
}
#if TARGET_OS_IOS
/**
@@ -1819,6 +1825,9 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
const CGSize calculatedSize = [node layoutThatFits:constrainedSize].size;
node.frame = { .size = calculatedSize };
// After the re-measurement, set the new constrained size to the node's backing colleciton element.
node.collectionElement.constrainedSize = constrainedSize;
// If the node height changed, trigger a height requery.
if (oldSize.height != calculatedSize.height) {
[self beginUpdates];