若是想去掉cell 中 某個footview 或 headview 不隨着tableview 一塊兒滾定,那麼我就就能夠重寫這個footview 或headview 的y 座標函數
方法以下 重寫footviewatom
#import <UIKit/UIKit.h>spa
@interface RRPSectionFootView :UIView.net
@property NSUInteger section;blog
@property (nonatomic,weak) UITableView *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