Skip to content

Instantly share code, notes, and snippets.

@lbrndnr
Created November 22, 2011 01:10
Show Gist options
  • Save lbrndnr/1384568 to your computer and use it in GitHub Desktop.
Save lbrndnr/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"];
}
@lbrndnr
Copy link
Author

lbrndnr commented Nov 22, 2011

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