采用监听方式
首先添加监听
[self.tableview addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil];
监听函数
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
if ([keyPath isEqualToString:@"contentOffset"]){
CGPoint offset = [change[NSKeyValueChangeNewKey] CGPointValue];
NSLog(@"%f",offset.y);
}
}