tableView的一些属性

 

    const NSUInteger numberOfSections = self.numberOfSections;spa

    const UIEdgeInsets contentInset = self.contentInset;it

    const CGPoint contentOffset = self.contentOffset;io

    

    const CGFloat sectionViewMinimumOriginY = contentOffset.y + contentInset.top + headerViewInsets.top;table

    

    // Layout each header viewast

    for(NSUInteger section = 0; section < numberOfSections; section++)class

    {im

        UIView* sectionView = [self headerViewForSection:section];next

        

        if(sectionView == nil)top

            continue;tab

        

        const CGRect sectionFrame = [self rectForSection:section];

        

        CGRect sectionViewFrame = sectionView.frame;

            

        sectionViewFrame.origin.y = ((sectionFrame.origin.y < sectionViewMinimumOriginY) ? sectionViewMinimumOriginY : sectionFrame.origin.y);

        // If it's not last section, manually 'stick' it to the below section if needed

        if(section < numberOfSections - 1)

        {

            const CGRect nextSectionFrame = [self rectForSection:section + 1];

            

            if(CGRectGetMaxY(sectionViewFrame) > CGRectGetMinY(nextSectionFrame))

                sectionViewFrame.origin.y = nextSectionFrame.origin.y - sectionViewFrame.size.height;

        }

        

//        TPLOG(@"%f",sectionViewFrame.origin.y);

        [sectionView setFrame:sectionViewFrame];

    }

这个是当tableVIew的

 UIEdgeInsets改变的时候,tableView的区头滑动不正常的处理,其中[self rectForSection:section]返回的是区头距离表头的绝对高度,不会改变,UIView* sectionView = [self headerViewForSection:section而这个view的frame确是相对的。这里的处理的逻辑就是当视图滑动的时候,在区头未滑倒顶部的时候,其view的高度设置成绝对高度,当在顶部停留的时候,再设置程偏移量,可实如今顶部的停留。

相关文章
相关标签/搜索