Skip to content

Instantly share code, notes, and snippets.

@lerboe
Created November 22, 2011 01:10
Show Gist options
  • Select an option

  • Save lerboe/1384568 to your computer and use it in GitHub Desktop.

Select an option

Save lerboe/1384568 to your computer and use it in GitHub Desktop.
Releasing unused UITableViewCells
-(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
NSMutableDictionary* cells = [self.tableView valueForKey:@"_reusableTableCells"];
for (UITableViewCell* cell in self.tableView.visibleCells) {
if ([cell.reuseIdentifier isEqualToString:@"Text"]) {
return;
}
}
[cells removeObjectForKey:@"Text"];
[self.tableView setValue:cells forKey:@"_reusableTableCells"];
}
@lerboe

lerboe commented Nov 22, 2011

Copy link
Copy Markdown
Author

When your UITableView displays different kind of UITableViewCells it's likely that there are cells that aren't displayed often. However, the TableView doesn't release them. With this little hack you can release the currently unused cells.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment