Ios 使用ASNetworkImageNode下载图像后,从AsyncDisplayKit重新布局ASTableView

Ios 使用ASNetworkImageNode下载图像后,从AsyncDisplayKit重新布局ASTableView,ios,objective-c,uitableview,asynchronous,asyncdisplaykit,Ios,Objective C,Uitableview,Asynchronous,Asyncdisplaykit,上下文: 我正在使用AsyncDisplayKit加载包含文本和图像的表。图像是从Internet下载的,在图像下载完成之前,图像大小未知 - (void)imageNode:(ASNetworkImageNode *)imageNode didLoadImage:(UIImage *)image { // Scale image downloaded from Internet to fit constrained width // Set networkImageNode

上下文: 我正在使用AsyncDisplayKit加载包含文本和图像的表。图像是从Internet下载的,在图像下载完成之前,图像大小未知

- (void)imageNode:(ASNetworkImageNode *)imageNode didLoadImage:(UIImage *)image {

    // Scale image downloaded from Internet to fit constrained width
    // Set networkImageNode to scaled image
    UIImage *newimage = [self scaleImage:image toConstrainedWidth:CONSTRAINED_WIDTH]; 
    self.networkImageNode.image = newimage;

    // Gets the parent cell 
    // Recalculate cell size and layout the cell (This works!)
    MyAsyncTableCellNode *parentCell = ASDisplayNodeFindClass(self, [MyAsyncTableCellNode class]);
    [parentCell invalidateCalculatedSize];
    [parentCell measure:CGSizeMake(CONSTRAINED_WIDTH, MAXFLOAT)];
    [parentCell layout];

    // Attempting to re-layout the table to shift the table cells
    // to accommodate for the new cell height (ALL these do NOT work!)
    MyAsyncTableViewController *parentTableViewController = ASDisplayNodeFindClass(self, [MyAsyncTableViewController class]);
    // Attempt #1
    [parentTableViewController.asyncTableView reloadData];

    // Attempt #2
    [parentTableViewController.asyncTableView beginUpdates];
    [parentTableViewController.asyncTableView endUpdates];
}
我想做什么: 图像下载完成后,我想重新调整单元格的大小和布局以适应图像,然后重新调整表格的大小和布局以适应新的单元格高度

到目前为止我所做的: 我最初仅使用文本绘制ASTableView,并使用ASNetworkingImage委托方法imageNode:didLoadImage方法在图像下载完成时获得通知

- (void)imageNode:(ASNetworkImageNode *)imageNode didLoadImage:(UIImage *)image {

    // Scale image downloaded from Internet to fit constrained width
    // Set networkImageNode to scaled image
    UIImage *newimage = [self scaleImage:image toConstrainedWidth:CONSTRAINED_WIDTH]; 
    self.networkImageNode.image = newimage;

    // Gets the parent cell 
    // Recalculate cell size and layout the cell (This works!)
    MyAsyncTableCellNode *parentCell = ASDisplayNodeFindClass(self, [MyAsyncTableCellNode class]);
    [parentCell invalidateCalculatedSize];
    [parentCell measure:CGSizeMake(CONSTRAINED_WIDTH, MAXFLOAT)];
    [parentCell layout];

    // Attempting to re-layout the table to shift the table cells
    // to accommodate for the new cell height (ALL these do NOT work!)
    MyAsyncTableViewController *parentTableViewController = ASDisplayNodeFindClass(self, [MyAsyncTableViewController class]);
    // Attempt #1
    [parentTableViewController.asyncTableView reloadData];

    // Attempt #2
    [parentTableViewController.asyncTableView beginUpdates];
    [parentTableViewController.asyncTableView endUpdates];
}
我能够成功地重新计算单个单元格的大小,重新布局并绘制单元格以适合下载的图像

问题: 但是,接下来我需要重新布局表格,以便向下或向上移动其他单元格,以适应更新单元格的新大小这是我无法工作的地方。

尝试#1将重新计算表的子视图并重新布局,但这也会重新加载所有数据,这不是我想要的。我只想重新计算和布局单元格,而不是重新加载所有数据

尝试#2:使用UITableView时,执行此操作将调用tableView:heightForRowAtIndexPath并重新布局所有表格单元格,但不幸的是,对于tableView,这会引发未实现的异常

问题:
如何以编程方式使ASTableView重新调整自身并考虑新的单元格高度?

您的第一次尝试应该是正确的,因为这将再次调用NumberOfSectionsTableView、NumberOfSectionsTableView、nodeForRowAtIndexPath方法,并且除非您指定,否则不应重新加载数据源(与常规UITableView一样)