Reputation: 14835
How do I make my UITableView cells == nil (make them not cached) when viewWillAppear happens? I want to completely reload all my cell views every time I come to the view. The main reason is because the backgroundView image of the cells may changed because of "themes" I'm adding to the app.
[tblView reloadData]
doesn't work on the cached views on the cell.
Upvotes: 0
Views: 637
Reputation: 30846
I would use -tableView:willDisplayCell:forRowAtIndexPath:
to determine and set the background views of your cell right before their drawn on screen. Obviously you'll want to use your datasource to determine which background view should be displayed.
Upvotes: 0
Reputation: 3921
Your cellForRowAtIndexPath method in your table view controller probably has two lines like:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
These lines attempt to reuse a previously created/formatted cell. To stop this reuse, take these lines out and instead just always allocate a new cell (i.e. something the equivalent of below).
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
Then when you do [tableView reloadData] in your viewWillAppear method it will always create brand new cells for each row rather than trying to reuse old ones.
Upvotes: 1
Reputation: 7819
Before you call reloadData, just let tableView:numberOfRowsInSection: return 0 first.
Then your table will have no row at all.
Upvotes: 0