How can I get a UITableView's visible rect?

Viewed 15023

I am trying to detect if the user has scrolled to the bottom of a UITableView so that I can do some additional stuff. In order to calculate things properly, I need to get the UITableView's visible rect. How can I achieve this?

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

    [_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];

    int currentMaxPosition = CGRectGetMaxY([self.tableView visibleRect]);
    int currentMinPosition = CGRectGetMinY([self.tableView visibleRect]);

    int tableViewBottom = [self.tableView bounds].size.height - 100;
    int tableViewTop = 0;

    //get older messages once we're near the bottom
    if (currentMaxPosition > tableViewBottom - 100)
    {
        NSLog(@"WE AT THE BOTTOM!");
    }      

}
5 Answers
Related