隐藏在tableview上方的视图

时间:2014-02-20 07:47:46

标签: iphone objective-c uitableview uiscrollview

我有一个高度为60的上层视图,我在y = 60时放置了tableview。我希望当我滚动表格时,我的上层视图应该隐藏,当我向下滚动时,它应该再次可见。但我无法做到这一点upperview作为tableview的标题。请帮助我如何在tableview中检测scrollview的方向,即它向上或向下移动。

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    int scrollPosition =   scrollView.contentOffset.y;

    if(upperview.frame.size.height<scrollPosition>1 && moveDirection = movingup){
        //code to make hide
    }else if(upperview.frame.size.height==scrollPosition>1 && moveDirection = movingDown){
        //code to show again
    }
       // But i have no idea how can i get this direction moveDirection = movingup or  moveDirection = movingDown
}

由于

1 个答案:

答案 0 :(得分:0)

我已经看过这个但是它总是遇到覆盖视图无法获得滚动视图加速的问题。在用户快速更改滚动速度期间,它会不匹配。

如果你不能使用表的标题视图,你可以将视图添加为坐标零上方滚动视图的子视图,然后更改UIScrollView的contentInset以允许它滚动到视线中。

相关问题