ericyue
ericyue

Reputation: 656

how to get the notification when UITableview 's section scroll to top?

I have a UITableView that contains many sections and each section has only one cell.

I want to get the notification when a section scroll to top (a section will disappear) and do something.

How to get the notification ?

Upvotes: 0

Views: 1081

Answers (2)

Paulo Casaretto
Paulo Casaretto

Reputation: 1017

Given UITableViewDelegate conforms to UIScrollViewDelegate, all you have to do is respond to this method:

- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView

Upvotes: 0

Leonardo
Leonardo

Reputation: 9857

You should try something like the following in your delegate method:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CGRect rect = [tableView rectForRowAtIndexPath:indexPath];
    float ypos = rect.origin.y;
    if(y==<your identifier for top>) {
      NSLog(@"I am on top");
    }
    // rest of your code...
}

If I understood correctly this should be what you need.

Upvotes: 2

Related Questions