zoukankan      html  css  js  c++  java
  • ios TableView那些事(二十 九)UITableViewController 粘合性

    如果想去掉cell 中 某个footview 或 headview 不随着tableview 一起滚定,那么我就就可以重写这个footview 或headview 的y 坐标

    方法如下 重写footview

     

    #import <UIKit/UIKit.h>

     

    @interface RRPSectionFootView :UIView

    @property NSUInteger section;

    @property (nonatomic,weakUITableView *tableView;

    @end

     

     

     

    #import "RRPSectionFootView.h"

     

    @implementation RRPSectionFootView

     

    - (void)setFrame:(CGRect)frame{

     

        CGRect sectionRect = [self.tableViewrectForFooterInSection:self.section]; // 重写MinY的坐标  如何想重写head   rectForHeaderInSection 就用这个函数替换上面的函数

        CGRect newFrame =CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(sectionRect), CGRectGetWidth(frame),CGRectGetHeight(frame));

        [super setFrame:newFrame];

    }

     

    @end

    去掉说有headview 的粘合性可以用下面方法

     

     

    #pragma mark- 去掉tableview headview黏性

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView {

        if (scrollView ==self.tableView)

        {

            CGFloat sectionHeaderHeight =10;

            if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {

                scrollView.contentInset =UIEdgeInsetsMake(-scrollView.contentOffset.y,0, 0, 0);

            } elseif (scrollView.contentOffset.y>=sectionHeaderHeight) {

                scrollView.contentInset =UIEdgeInsetsMake(-sectionHeaderHeight, 0,0, 0);

            }

        }

    }

    http://blog.csdn.net/lengshengren/article/details/44237929

  • 相关阅读:
    CF833 A The Meaningless Game
    [Noip2016]蚯蚓 (单调队列)
    [NOI2003]逃学的小孩 (贪心+树的直径+暴力枚举)
    [POI2014]FAR-FarmCraft (树规+贪心)
    洛谷P2566 [SCOI2009]围豆豆(状压dp+spfa)
    [POJ1852] Ants(思维题)
    树的深度(我觉得没毛病)
    HDU
    剑指offer相关问题
    CC150相关问题
  • 原文地址:https://www.cnblogs.com/NSong/p/6567907.html
Copyright © 2011-2022 走看看