关于UICollectionView的headerView的问题
来源:互联网 发布:富木制衣淘宝旗舰店 编辑:程序博客网 时间:2024/06/05 15:11
1.collectionView的注意事项:必须注册cell;如果在storyboard添加了可重用标示符,可以不注册.
必须实现代理方法.否则会报错.
当cell的大小显示不正常的时候,可以试一下在视图加载完成之后,将要出现的时候,设置itemSize; 注册cell的方法会跳到dequeueReusableCellWithReuseIdentifier:(缓存池中调用cell),如果缓存池中没有会创建cell,这时候会自动调用 -(instancetype)initWithFrame:(CGRect)frame这个方法.
在storyboard 中设置cell的颜色不起作用,要在控制器中用代码设置.
2.collectionView纯代码设置组头:
-(CGSize)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
if(section == 0)
{
CGSize size = {320, 150};
return size;
} else
{
CGSize size = {320, 50};
return size;
}
}
3.
#warning 如果在storboard中设置了组头或组尾,必须设置重用标识符
//这个方法必须要在storyboard中设置可视化header,footer,可重用标示符,才会起作用
// static NSString *headerIdentifier = @"header";
UICollectionReusableView *resuableView;
// headerIdentifier = (kind == UICollectionElementKindSectionHeader) ? @"header" : @"footer";
if(kind ==UICollectionElementKindSectionHeader){
resuableView = [collectionView dequeueReusableSupplementaryViewOfKind:kindwithReuseIdentifier:@"header"forIndexPath:indexPath];
// return resuableView;
}else{
resuableView = [collectionView dequeueReusableSupplementaryViewOfKind:kindwithReuseIdentifier:@"footer"forIndexPath:indexPath];
// return resuableView;
}
return resuableView;
}
4. 2的方法和3的方法同时使用会报错.
- 关于UICollectionView的headerView的问题
- UICollectionView的HeaderView、FooterView
- UicollectionView的headerView重叠
- UICollectionView headerView悬浮 类似于UItableView的Section
- 关于ListView的HeaderView
- 关于ListView的HeaderView
- IOS-UICollectionView的基本使用以及添加headerView
- 为UICollectionView的每个section设置footerView和headerView
- 95.UICollectionView添加headerView(类似UITableView的tableHeaderView)
- swift中UICollectionView的使用(headerview/footerview/cell/model)
- iOS 11 下 UICollectionView 的HeaderView 遮挡滚动条
- 关于tableview的headerview遮挡住cell的问题
- iOS 关于UICollectionView的cell重用问题
- 关于UICollectionView 自动滑动的问题
- ListView关于添加HeaderView,FooterView的小问题
- UICollectionView Section 纯代码代码控制 HeaderView和FooterView的显示,uicollectionview
- 解决headerView 的resize问题
- tableview 的 headerview 滑动问题
- 运行APP时dex2oat过程中无法在系统中创建文件夹
- Win8下VS 2015安装记录
- 自定义View系列一 自定义View的构造函数,自定义属性
- [BZOJ3231] [Sdoi2008]递归数列
- Python命令Tab自动补全脚本
- 关于UICollectionView的headerView的问题
- 运行APP时dex2oat过程中DumpLIRInsn函数出错
- Leetcode #42. Trapping Rain Water 雨水收集 解题报告
- poj 1118 Lining Up
- C++实验3-个人所得税计算器
- My First CSDN Article
- 我是一个线程
- iOS instruments介绍
- hihoCoder 1043 完全背包