views:

97

answers:

1

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] the data did get refreshed but the subviews added to the contentview of the cells previously persisted.

How do I achieve this??? Thanks in advance!

A: 

I got the answer :)

    if ([cell.contentView subviews]){
    for (UIView *subview in [cell.contentView subviews]) {
        [subview removeFromSuperview];
    }
}

This piece of code will check if the cell's content view has any subviews.
If there are any, it removes them as the for loop iterates!

Bangdel