objective-c – 快速滚动时不调用UIScrollView scrollViewDidEndDragging

我已经实现了scrollViewDidEndDragging 🙁 UIScrollView *)scrollView willDecelerate:(BOOL)在我的UIScrollViewDelegate中减速.除非我非常快速地滚动,否则该方法被称为没有问题.例如,如果我进行三次快速滑动,即使滚动视图将(正确)页面三次,该方法也只会被调用一次.

有没有解决这个问题?我依赖这个方法来实现正确的延迟加载行为,当它没有被调用时,意味着事情不会及时加载.如果没有这种方法的解决方案,是否有其他方法可以让我知道每次用户从滚动视图中抬起手指?

最佳答案 哇老问题,但无论如何这里是anwser.

scrollView.delegate = self; // or some .m file

然后在实施中

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    NSLog(@"Just a usual drag!");
}

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
    // so when dragged quickly, this function will be called instead of didEndDragging
    // now lets trick it to stop the animation of decelerating
    [scrollView setContentOffset:[scrollView contentOffset] animated:NO];
    // and then call the dragging event like nothing even happened
    [scrollView.delegate scrollViewDidEndDragging:scrollView willDecelerate:NO];
}
点赞