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的高度設置成絕對高度,當在頂部停留的時候,再設置程偏移量,可實如今頂部的停留。

相關文章
相關標籤/搜索