如何禁止UITableView垂直向上滚动? [英] How to disable a UITableView from scrolling up vertically?

查看:95
本文介绍了如何禁止UITableView垂直向上滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UITableView中使用 EGORefreshTableHeader 和静态单元格(在nib中定义)。

I'm using EGORefreshTableHeader in conjunction with a static cell (defined in a nib) in a UITableView.

我希望能够向下滚动tableview以触发 EGORefreshTableHeader ,从而刷新数据静态细胞。但是,由于静态单元的大小完全适合窗口,我想阻止人们向上滚动。

I'd like to be able to scroll the tableview down to trigger the EGORefreshTableHeader and thus refresh the data in the static cell. BUT, as the static cell is sized to fit perfectly in the window, I want to prevent folks from being able to scroll up.

有没有办法做到这一点?

Is there a way to do this?

推荐答案

试试这个:

CGFloat a;

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    a = scrollView.contentOffset.y;
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView.contentOffset.y > a) 
    {
        [scrollView setScrollEnabled:NO];
        [scrollView setContentOffset:CGPointMake(0, a)];
    }
    [scrollView setScrollEnabled:YES];
}

这篇关于如何禁止UITableView垂直向上滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆