美文网首页IOS进阶iOS进阶指南iOS Developer
如何判断UITableViewCell已经消失

如何判断UITableViewCell已经消失

作者: 孤獨的守望者 | 来源:发表于2016-03-25 15:06 被阅读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);
    }
}

相关文章

网友评论

本文标题:如何判断UITableViewCell已经消失

本文链接:https://www.haomeiwen.com/subject/gwfdlttx.html