Skip to content

Instantly share code, notes, and snippets.

@shiweifu
Created January 2, 2014 11:53
Show Gist options
  • Select an option

  • Save shiweifu/8218177 to your computer and use it in GitHub Desktop.

Select an option

Save shiweifu/8218177 to your computer and use it in GitHub Desktop.
get all cells in UITableView
//get all UITableViewCell
-(NSArray *)cellsForTableView
{
UITableView *tableView = self.tableView;
NSInteger sections = tableView.numberOfSections;
NSMutableArray *cells = [[NSMutableArray alloc] init];
for (int section = 0; section < sections; section++) {
NSInteger rows = [tableView numberOfRowsInSection:section];
for (int row = 0; row < rows; row++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];//**here, for those cells not in current screen, cell is nil**
[cells addObject:cell];
}
}
return cells;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment