在tableview图像子视图中更新图像的最佳方法是什么? [英] What's the best way to update an image in my tableview image subview?

查看:80
本文介绍了在tableview图像子视图中更新图像的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具体来说,如何从uitableview单元格中获取图像子视图?

Specifically, how do you get the image subview from a uitableview cell?

我的表视图以异步方式从Web获取数据。当我第一次创建图像视图时,我添加了视图:

My table view gets data from the web asynchronously. When I created the image view the first time, I added the view by:

[imageView setImage:image];
[cell addSubview:imageView];

tableView:cellForRowAtIndexPath:

检索新数据后,我调用 reloadData 刷新表视图。但是要更新图像,我想获得这个imageView的句柄(如果存在)并更新图像。

After new data is retrieved, I call reloadData to refresh the table view. But to update the image, I'd like to get a handle of this imageView (if it exist) and update the image.

我的问题是:给定单元格,有没有办法直接获取这个图像视图(句柄),还是我必须遍历子视图才能找到特定的图像视图?

My question is: Given the cell, is there a way to get this image view (handle) directly , or do I have to loop through the subviews to find the specific image view?

任何答案都非常感谢!

Lu

推荐答案

当你在imageView上设置标签创建它:

Set a tag on the imageView when you create it:

 [image viewSetTag: uniqueIntValue];

然后当你想要获取视图时使用:

Then when you want to grab the view use:

UIView* recoveredImageView = [cell viewWithTag uniqueIntValue];

这篇关于在tableview图像子视图中更新图像的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆