在tableview图像子视图中更新图像的最佳方法是什么?

编程入门 行业动态 更新时间:2024-10-20 03:27:32
本文介绍了在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图像子视图中更新图像的最佳方法是什么?

本文发布于:2023-11-26 13:14:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634002.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   视图   方法   tableview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!