Created
January 2, 2014 11:53
-
-
Save shiweifu/8218177 to your computer and use it in GitHub Desktop.
get all cells in UITableView
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
| //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