Reputation: 28907
How do I remove a Subview from a UITableViewCell's content view?
For instance, I have added the following subview to my cell's content view.
UIButton *b = etc.
[cell.contentView addSubview:b];
Now I'd like to remove it: ?
Upvotes: 2
Views: 6244
Reputation: 3486
One line
[cell.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
Upvotes: 0
Reputation: 256
This code remove all subviews on cell:
if ([cell.contentView subviews]){
for (UIView *subview in [cell.contentView subviews]) {
[subview removeFromSuperview];
}
}
Upvotes: 12