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

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

Merged
merged 6 commits into from
May 28, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 invalid layout of a cell node during height query. [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)
Expand Down
6 changes: 4 additions & 2 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,13 @@ - (BOOL)zeroContentInsets
- (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;
Expand Down
10 changes: 8 additions & 2 deletions Source/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

- (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;
}
Copy link
Contributor

@maicki maicki May 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need the else case and use the cached size: node.calculatedSize.height;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we don't. -layoutThatFits: checks and uses the cached size if possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we assert that node exists?


#if TARGET_OS_IOS
/**
Expand Down