一、获取当前tableView中所有cell
-(NSArray *)allTableViewCellsArray
{
NSMutableArray *cells = [[NSMutableArray alloc] init];
for (NSInteger j = 0; j < [self.tableView numberOfSections]; ++j)
{
for (NSInteger i = 0; i < [self.tableView numberOfRowsInSection:j]; ++i)
{
[cells addObject:[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]]];
}
}
return cells;
}
二、获取section这所有cell
- (NSArray *)tableView:(UITableView *)tableView cellsInSection:(NSInteger)section
{
NSPredicate *visibleCellsInSectionPredicate = [NSPredicate predicateWithBlock:^BOOL(UITableViewCell *visibleCell, NSDictionary *bindings) {
return [tableView indexPathForCell:visibleCell].section == section;
}];
return [[self allTableViewCellsArray] filteredArrayUsingPredicate:visibleCellsInSectionPredicate];
}
网友评论