上下文: 我使用AsyncDisplayKit来加载包含文本和图像的表.图像从Internet下载,图像大小未知,直到图像下载完毕.
我正在尝试做的事情: 图像下载完成后,我想重新调整大小并布置单元格以适应图像,然后重新调整大小并布置表格以适应新的单元格高度.
到目前为止我做了什么: 我最初只用文本绘制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 …Run Code Online (Sandbox Code Playgroud)