Created
November 22, 2011 01:10
-
-
Save lbrndnr/1384568 to your computer and use it in GitHub Desktop.
Releasing unused UITableViewCells
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(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"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.