Determine if a tableview cell is visible

前端 未结 8 1278
野性不改
野性不改 2020-12-02 13:13

Is there any way to know if a tableview cell is currently visible? I have a tableview whose first cell(0) is a uisearchbar. If a search is not active, then hide cell 0 via a

相关标签:
8条回答
  • 2020-12-02 13:43

    Swift Version:

    if let indices = tableView.indexPathsForVisibleRows {
        for index in indices {
            if index.row == 0 {
                return true
            }
        }
    }
    return false
    
    0 讨论(0)
  • 2020-12-02 13:44

    IOS 4:

    NSArray *cellsVisible = [tableView indexPathsForVisibleRows];
    NSUInteger idx = NSNotFound;
    idx = [cellsVisible indexOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop)
    {
        return ([(NSIndexPath *)obj compare:indexPath] == NSOrderedSame);
    }];
    
    if (idx == NSNotFound)
    {
    
    0 讨论(0)
提交回复
热议问题