ios TableView那些事(二十 九)UITableViewController 粘合性

若是想去掉cell 中 某个footview 或 headview 不随着tableview 一块儿滚定,那么我就就能够重写这个footview 或headview 的y 坐标函数

方法以下 重写footviewatom

 

#import <UIKit/UIKit.h>spa

 

@interface RRPSectionFootView :UIView.net

@property NSUInteger section;blog

@property (nonatomic,weakUITableView *tableView;it

@endio

 

 

 

#import "RRPSectionFootView.h"table

 

@implementation RRPSectionFootViewclass

 

- (void)setFrame:(CGRect)frame{import

 

    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

相关文章
相关标签/搜索