Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove the subviews from the contentView of UITableViewCell (reset the UITableView)

Any idea on how to reset a UITableView?

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.

like image 947
Bangdel Avatar asked Sep 21 '10 10:09

Bangdel


1 Answers

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] ;
like image 182
leftspin Avatar answered Oct 05 '22 23:10

leftspin