具体来说,如何从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图像子视图中更新图像的最佳方法是什么?
发布评论