2
如何從UITableViewCell的內容視圖中刪除子視圖?從UITableViewCell的內容視圖中刪除子視圖
例如,我在我的單元格的內容視圖中添加了以下子視圖。
UIButton *b = etc.
[cell.contentView addSubview:b];
現在我想刪除它: ?
如何從UITableViewCell的內容視圖中刪除子視圖?從UITableViewCell的內容視圖中刪除子視圖
例如,我在我的單元格的內容視圖中添加了以下子視圖。
UIButton *b = etc.
[cell.contentView addSubview:b];
現在我想刪除它: ?
該代碼去除細胞的所有子視圖:
if ([cell.contentView subviews]){
for (UIView *subview in [cell.contentView subviews]) {
[subview removeFromSuperview];
}
}
一號線
[cell.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];