备忘

来源:互联网 发布:淘宝白菜群 编辑:程序博客网 时间:2024/06/05 02:15
- (void)setTableOffset:(UIScrollView *)scrollView{    CGFloat deltaY = scrollView.contentOffset.y - m_preOffsetY;    CGFloat height = self.frame.size.height;    CGFloat cellHeight = height - SECTION_HEADER_HEIGHT - SECTION_FOOTER_HEIGHT;    if (deltaY < cellHeight / 2 && deltaY >= 0)    {        [scrollView setContentOffset:CGPointMake(0, m_preOffsetY) animated:YES];    }    else if (deltaY >= cellHeight / 2)    {        [scrollView setContentOffset:CGPointMake(0, m_preOffsetY + cellHeight) animated:YES];        m_preOffsetY = m_preOffsetY + cellHeight;    }    else if (deltaY > -cellHeight / 2 && deltaY < 0)    {        [scrollView setContentOffset:CGPointMake(0, m_preOffsetY) animated:YES];    }    else if (deltaY <= -cellHeight / 2)    {        [scrollView setContentOffset:CGPointMake(0, m_preOffsetY - cellHeight) animated:YES];        m_preOffsetY = m_preOffsetY - cellHeight;    }}

- (void)setTableOffset:(UIScrollView *)scrollView{    NSInteger cellHeight = self.frame.size.height - SECTION_HEADER_HEIGHT - SECTION_FOOTER_HEIGHT;    CGFloat deltaY = (NSInteger)self.contentOffset.y % cellHeight;    NSInteger curIndex = self.contentOffset.y / cellHeight;    BOOL isFullPage = [UPMathUtil isZero:deltaY precesion:0.1];    if (!isFullPage)    {        if (deltaY >= cellHeight / 2)        {            CGFloat offsetY = cellHeight * (curIndex + 1);          //  self.contentOffset = CGPointMake(0, offsetY);               [self setContentOffset:CGPointMake(0, offsetY) animated:YES];        }        else        {            CGFloat offsetY = cellHeight * curIndex;         //   self.contentOffset = CGPointMake(0, offsetY);               [self setContentOffset:CGPointMake(0, offsetY) animated:YES];        }    }}

0 0
原创粉丝点击