1
votes

I have UITableView which can contain different number of cells.

So I would like to show top & bottom arrows (like on the picture below) if UITableView has hidden cells on top or bottom and hide them if all UITableView's cell are visible.

enter image description here

I have implemented UIScrollView delegate method to detect UITableView's scrolling:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{

}

but don't know how to check if first or last cell is not visible.

EDITED

Here is the solution:

        if (self.ingredientsTableView.contentOffset.y<0){
            [ingrUpArrow setHidden:YES];
        }
        else if (self.ingredientsTableView.contentOffset.y == 0) {
            [ingrUpArrow setHidden:YES];
        }
        else if (self.ingredientsTableView.contentOffset.y >= (self.ingredientsTableView.contentSize.height - self.ingredientsTableView.bounds.size.height)) {
            [ingrUpArrow setHidden:NO];
            [ingrDownArrow setHidden:YES];
        }
        else {
            [ingrUpArrow setHidden:NO];
            [ingrDownArrow setHidden:NO];
        }
1

1 Answers

1
votes

There are many useful properties of UItableView which can be used in such cases and tableView.contentOffset.y is one of it. Use it. Also this can be useful.