相关疑难解决方法(0)

检测UITableView的底部"反弹"

我有一个表视图,当用户向下滚动UITableView(向上推拇指)时执行动画,当用户在UITableView上向上滚动(按下拇指向下)时,执行不同的动画.

问题是当用户到达UITableView的底部并且它反弹时,表会记录向上然后向下移动,从而在不应该执行时执行动画.

滚动到顶部时会发生同样的确切行为; 但是,我能够像这样检测它:

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {

    self.lastContentOffset = scrollView.contentOffset;

}


-(void) scrollViewDidScroll:(UIScrollView *)scrollView {

    // Check if we are at the top of the table
    // This will stop animation when tableview bounces

    if(self.tableView.contentOffset.y < 0){
        // Dont animate, top of tableview bounce


    } else {

        CGPoint currentOffset = scrollView.contentOffset;

        if (currentOffset.y > self.lastContentOffset.y) {

            // Downward animation
            [self animate:@"Down"];

        } else {

            // Upward
            [self animate:@"Up"];

        }

        self.lastContentOffset = currentOffset;

    }

}
Run Code Online (Sandbox Code Playgroud)

这很完美,但对于我的生活,我无法弄清楚是否有条件来检测底部.我确信这很简单,我只是想不通.

uitableview uiscrollviewdelegate ios

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

ios ×1

uiscrollviewdelegate ×1

uitableview ×1