【发布时间】:2011-06-06 14:29:19
【问题描述】:
如何从 UITableViewCell 的内容视图中删除子视图?
例如,我在单元格的内容视图中添加了以下子视图。
UIButton *b = etc.
[cell.contentView addSubview:b];
现在我想删除它: ?
【问题讨论】:
标签: uiview uitableview
如何从 UITableViewCell 的内容视图中删除子视图?
例如,我在单元格的内容视图中添加了以下子视图。
UIButton *b = etc.
[cell.contentView addSubview:b];
现在我想删除它: ?
【问题讨论】:
标签: uiview uitableview
此代码删除单元格上的所有子视图:
if ([cell.contentView subviews]){
for (UIView *subview in [cell.contentView subviews]) {
[subview removeFromSuperview];
}
}
【讨论】:
一行
[cell.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
【讨论】: