如何要求从 UITableViewCell(TTTableViewCell) 内部重新计算 UITableView(TTTableView) 的大小

发布于 2024-11-07 19:59:27 字数 202 浏览 4 评论 0原文

我的表格视图单元格 (TTTTableViewCells) 单元格包含从互联网异步加载的图像。加载图像时,表格视图单元格会从 TTImageView 对象获取回调。

问题是在回调时我如何要求父 TTTableView 更改单元格的高度并相应地调整大小。

似乎对 heightForRowAtIndexPath 的调用仅在 tableview 绘制开始时进行。

My tableview cells (TTTAbleViewCells) cells contain images that are loaded from the internet aynchronously.When the image is loaded the the table view cell gets a callback from the TTImageView object.

Question is at the point of the callback how can i ask the parent TTTableView to change the height of the cells and resize accordingly.

It seems like the call to heightForRowAtIndexPath is only at the beginning of tableview drawing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷迭香的记忆 2024-11-14 19:59:27

我认为这是不可能的。我建议调整图像大小以适合您的单元格,而不是反之亦然

I don't think this is possible. I'd recommend resizing your images to fit into your cells, rather than vice-versa

我们的影子 2024-11-14 19:59:27

我想我会在这里回答我自己的问题。

- (void)imageView:(TTImageView*)imageView didLoadImage:(UIImage*)image
{
    [self setNeedsLayout];
    NSIndexPath *indexPath = [(UITableView *)self.superview indexPathForCell:self];
    if(indexPath!=nil)
    {   
        NSArray* path = [NSArray arrayWithObject:indexPath];
        [(UITableView*)[self superview] reloadRowsAtIndexPaths:path withRowAnimation:UITableViewRowAnimationNone];
    }   
}

I guess I will answer my own question here.

- (void)imageView:(TTImageView*)imageView didLoadImage:(UIImage*)image
{
    [self setNeedsLayout];
    NSIndexPath *indexPath = [(UITableView *)self.superview indexPathForCell:self];
    if(indexPath!=nil)
    {   
        NSArray* path = [NSArray arrayWithObject:indexPath];
        [(UITableView*)[self superview] reloadRowsAtIndexPaths:path withRowAnimation:UITableViewRowAnimationNone];
    }   
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文