views:

139

answers:

2

I think the title explains it all. I want to be notified when a user scrolls to the top of a tableview.

I've tried the following with no luck and even added a UIScrollViewDelegate to the .h file.

- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView{
    NSLog(@"ScrolledToTop");
}

Thanks!

Edit: I can get it to call if I press the status bar. But not if I scroll to the top. Weird... could it have something to do with the tableview bouncing when it reaches the top?

+1  A: 
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

if (indexPath.row == 0 && indexPath.section == 0 ) {
    NSLog(@"Showing top cell");

}

Is that close enough?

justin
Actually, it's not. I want it to call when it reaches the top of the tableview header. Not the first cell. Thanks for the help though!
Jonah
+1  A: 

What happens if you try this?

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView.contentOffset.y == 0)
        NSLog("At the top");
}
Mike McMaster
That did it! Thanks!
Jonah