自定义tableView的section header/footerView时的view复用问题
来源:互联网 发布:网络优化工程师培训 编辑:程序博客网 时间:2024/06/06 11:38
1.首先要自定义一个sectionHeadView/sectionFootView继承自UITableViewHeaderFooterView,如下:
@interfaceFriendCircleView : UITableViewHeaderFooterView
2.在自定义的sectionHeadView/sectionFootView中重写这个方法,设置复用
- (instancetype)initWithReuseIdentifier:(NSString*)reuseIdentifier{
self = [superinitWithReuseIdentifier:reuseIdentifier];
if (self) {
self = [superinitWithReuseIdentifier:reuseIdentifier];
if (self) {
[self_init];//_init表示初始化方法
}
return self;
return self;
}
3.在需要调用自定义sectionHeadView/sectionFootView的VC里面调用table的代理方法,用法跟cell的复用相似
- (nullableUIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section{
static NSString *viewIdentfier =@"headView";
FriendCircleView *sectionHeadView = [tableViewdequeueReusableHeaderFooterViewWithIdentifier:viewIdentfier];
if(!sectionHeadView){
sectionHeadView = [[FriendCircleViewalloc]initWithReuseIdentifier:viewIdentfier];
}
sectionHeadView.friendCircleModel= _postArray[section];
return sectionHeadView;
static NSString *viewIdentfier =@"headView";
FriendCircleView *sectionHeadView = [tableViewdequeueReusableHeaderFooterViewWithIdentifier:viewIdentfier];
if(!sectionHeadView){
sectionHeadView = [[FriendCircleViewalloc]initWithReuseIdentifier:viewIdentfier];
}
sectionHeadView.friendCircleModel= _postArray[section];
return sectionHeadView;
}
4.若想改变自定义区头的背景色,需设置:
self.contentView.backgroundColor= [UIColorwhiteColor];
0 0
- 自定义tableView的section header/footerView时的view复用问题
- 自定义tableview的footerview
- ios tableView 的header for section无法加载的问题
- tableView的每个section 的headerView或者footerView随tableView一起滚动
- tableview自定义每个section的title
- 自定义tableview Header和Footer的样式
- 【iOS】TableView的footerView不随cell滚动而停留在tableView底部的问题
- TableView的footerView不随cell滚动而停留在tableView底部的问题,ios tableviewfooter
- tableview的headerview和footerview的做法
- 让UITableView的section header view不悬停的方法
- 让UITableView的section header view不悬停的方法
- 让UITableView的section header view不悬停的方法
- 让UITableView的section header view不悬停的方法
- UITableView的section header view悬停和取消的方法
- 让UITableView的section header view不悬停的方法
- OC笔记 - 自定义tableView的headerView(footerView)(2015.3.13)
- 让UITableView的section header view不悬停,让UITableView的section headerview取消粘性
- xcode 中tableView的section自定义…
- Android Studio 连接不上真机
- 剖析C数据类型和变量
- 程序员的搞笑日常生活
- Android 通过solid来定义不同边框的颜色,可以只定义一个边框的颜色
- struts2.3.28升级
- 自定义tableView的section header/footerView时的view复用问题
- swift2.0 学习笔记six
- 设置ViewPager不能进行滑动
- cocos2d-x 特效(网格动作)
- 文章标题
- 域名检测配置信息
- 内存空间布局:代码段、数据段,栈,堆 ,寄存器
- __I、 __O 、__IO是什么意思?怎么用?
- Java入门 第二季第四章 多态