【问题标题】:How to detect UITableView scrolling down only in iOS?如何检测 UITableView 仅在 iOS 中向下滚动?
【发布时间】:2014-02-08 09:39:16
【问题描述】:

现在我可以使用以下代码检测UITableView 上下滚动。

但是我只想在向下滚动时触发事件。不包括上滚动。

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate 中使用这些代码

NSInteger currentOffset = scrollView.contentOffset.y;
    NSInteger maximumOffset = scrollView.contentSize.height - scrollView.frame.size.height;

if (maximumOffset - currentOffset <= 20.0) {
        //        [self methodThatAddsDataAndReloadsTableView];

如何仅检测UITableView 中向下滚动到底部。

【问题讨论】:

    标签: uitableview ios7 uiscrollview


    【解决方案1】:

    当拖动结束时,您可以将当前contentOffset 与目标contentOffset 进行比较。或查看scrolling速度标志:

    - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView 
                         withVelocity:(CGPoint)velocity 
                  targetContentOffset:(inout CGPoint *)targetContentOffset {
        NSLog(@"%@", scrollView.contentOffset.y > targetContentOffset->y ? @"top" : @"bottom");
        NSLog(@"%@", velocity.y > 0 ? @"bottom" : @"top");
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-11
      • 1970-01-01
      • 2010-12-07
      • 1970-01-01
      • 2019-06-30
      • 1970-01-01
      • 2013-05-23
      相关资源
      最近更新 更多