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

Crash when using ASTableNode convert(_ rect:,from:) with ASCellNode method #58

Closed
siuying opened this issue Apr 23, 2017 · 2 comments
Closed

Comments

@siuying
Copy link

siuying commented Apr 23, 2017

I tried to retrieve the frame of an ASCellNode within its container ASTableNode. I need this to animate transition of the cell to next screen.

When I called tableNode.convert(cell.frame, from: cell), I expected to return the cell frame in the table coordinate. instead I get error: Could not find a common ancestor between node1: <MyCellNode: 0x7fee331bb000> and node2: <ASTableNode: 0x7fee32e0d5d0>

This is weird, can a table node not the ancestor of a cell node?

This can be reproduced by adding two lines to AsyncDisplayKit/examples/ASViewControllerSample/ViewController.m

- (void)tableNode:(ASTableNode *)tableNode didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // add these two lines to get the Rect of the cell node... 
    // it will crash the app when user tap a row
    ASCellNode* cell = [tableNode nodeForRowAtIndexPath:indexPath];
    CGRect rect = [tableNode convertRect:cell.frame fromNode:cell];

    NSString *imageCategory = self.imageCategories[indexPath.row];
    DetailRootNode *detailRootNode = [[DetailRootNode alloc] initWithImageCategory:imageCategory];
    DetailViewController *detailViewController = [[DetailViewController alloc] initWithNode:detailRootNode];
    detailViewController.title = [imageCategory capitalizedString];
    [self.navigationController pushViewController:detailViewController animated:YES];
}
@Adlai-Holler
Copy link
Member

@siuying Ah that makes sense – the cell node is not a direct subnode of the table node. The cell node is inside a view (the UITableViewCell) which is inside the table view.

Instead use -[ASTableNode rectForRowAtIndexPath:] to get the rect in the table node's coordinate system. Thanks for raising the issue and sorry for the confusion!

@siuying
Copy link
Author

siuying commented Apr 25, 2017

Thanks a lot for the pointer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants