IOS进阶iOS进阶指南iOS Developer

如何判断UITableViewCell已经消失

2016-03-25  本文已影响2630人  孤獨的守望者

直接上代码了

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellIdentifiy = @"CELL";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifiy];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifiy];
    }
    cell.textLabel.text = _items[indexPath.row];
    [_set addObject:indexPath];
    NSLog(@"%@在唱歌", _items[indexPath.row]);
    return cell;
}

#pragma mark -
#pragma mark -UIScrollView delegate
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView
                  willDecelerate:(BOOL)decelerate {
    NSSet *visiblecells = [NSSet setWithArray:[self.contextView indexPathsForVisibleRows]];
    [_set minusSet:visiblecells];
    
    for (NSIndexPath *anIndexPath in _set) {
        UITableViewCell *cell = [self.contextView dequeueReusableCellWithIdentifier:@"CELL" forIndexPath:anIndexPath];
        NSLog(@"%@不在唱歌", cell.textLabel.text);
    }
}
上一篇 下一篇

猜你喜欢

热点阅读