从UITableViewCell的contentView中删除子视图(重置UITableView) [英] remove the subviews from the contentView of UITableViewCell (reset the UITableView)

查看:90
本文介绍了从UITableViewCell的contentView中删除子视图(重置UITableView)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关如何重置 UITableView 的任何想法?

Any idea on how to reset a UITableView?

我想按一个按钮显示一组新数据,并从单元格的 contentView 并使用一组新的子视图刷新它们。我尝试了 [tableView reloadData] ,但数据确实已刷新,但子视图已添加到以前保留的单元格的 contentView 中。

I want to display a new set of data at the press of a button and also remove all the subviews from the cell's contentView and refresh them with a new set of subviews. I tried [tableView reloadData] but the data did get refreshed but the subviews added to the contentView of the cells previously persisted.

推荐答案

更好的是,当你创建单元格时:

Better yet, when you create the cell:

#define MY_CUSTOM_TAG 1234
mySubview.tag = MY_CUSTOM_TAG;
[cell.contentView addSubview:mySubview] ;

稍后,当您需要将其删除时:

And later on, when you need to remove it:

[[cell.contentView viewWithTag:MY_CUSTOM_TAG]removeFromSuperview] ;

这篇关于从UITableViewCell的contentView中删除子视图(重置UITableView)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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