collectionView的注意事项
2016-01-07 15:30
302 查看
1:有headerView 和 footerView
做法:
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath
*)indexPath
{
UICollectionReusableView *reusableView =
nil;
if (kind ==
UICollectionElementKindSectionHeader) {
if (indexPath.section ==
2) {
YQHomeJieDuanCollectionReusableView *reviewHeader = [collectionView
dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:@"YQHomeJieDuanCollectionReusableView"
forIndexPath:indexPath];
reusableView = reviewHeader;
}
}
if (kind ==
UICollectionElementKindSectionFooter) {
YQSectionCollectionReusableView *reViewFooter = [collectionView
dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter
withReuseIdentifier:@"YQSectionCollectionReusableView"
forIndexPath:indexPath];
reusableView = reViewFooter;
}
return reusableView;
}
2:cell用xib的话别忘了注册。
做法:
UINib *nib = [UINib
nibWithNibName:@"YQHomeFeedBigImageCollectionViewCell"
bundle:nil];
[self.baseCollectionView
registerNib:nib forCellWithReuseIdentifier:@"YQHomeFeedBigImageCollectionViewCell"];
3:xib 做成的headerView或者footerView 要手动将xib 的引用类改为自己建的类名。要不然会崩溃
4:注册headerView或者footerView
做法:
UINib *nib5 = [UINib
nibWithNibName:@"YQHomeJieDuanCollectionReusableView"
bundle:nil];
[self.baseCollectionView
registerNib:nib5 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:@"YQHomeJieDuanCollectionReusableView"];
UINib *nib6 = [UINib
nibWithNibName:@"YQSectionCollectionReusableView"
bundle:nil];
[self.baseCollectionView
registerNib:nib6 forSupplementaryViewOfKind:UICollectionElementKindSectionFooter
withReuseIdentifier:@"YQSectionCollectionReusableView"];
做法:
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath
*)indexPath
{
UICollectionReusableView *reusableView =
nil;
if (kind ==
UICollectionElementKindSectionHeader) {
if (indexPath.section ==
2) {
YQHomeJieDuanCollectionReusableView *reviewHeader = [collectionView
dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:@"YQHomeJieDuanCollectionReusableView"
forIndexPath:indexPath];
reusableView = reviewHeader;
}
}
if (kind ==
UICollectionElementKindSectionFooter) {
YQSectionCollectionReusableView *reViewFooter = [collectionView
dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter
withReuseIdentifier:@"YQSectionCollectionReusableView"
forIndexPath:indexPath];
reusableView = reViewFooter;
}
return reusableView;
}
2:cell用xib的话别忘了注册。
做法:
UINib *nib = [UINib
nibWithNibName:@"YQHomeFeedBigImageCollectionViewCell"
bundle:nil];
[self.baseCollectionView
registerNib:nib forCellWithReuseIdentifier:@"YQHomeFeedBigImageCollectionViewCell"];
3:xib 做成的headerView或者footerView 要手动将xib 的引用类改为自己建的类名。要不然会崩溃
4:注册headerView或者footerView
做法:
UINib *nib5 = [UINib
nibWithNibName:@"YQHomeJieDuanCollectionReusableView"
bundle:nil];
[self.baseCollectionView
registerNib:nib5 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:@"YQHomeJieDuanCollectionReusableView"];
UINib *nib6 = [UINib
nibWithNibName:@"YQSectionCollectionReusableView"
bundle:nil];
[self.baseCollectionView
registerNib:nib6 forSupplementaryViewOfKind:UICollectionElementKindSectionFooter
withReuseIdentifier:@"YQSectionCollectionReusableView"];
相关文章推荐
- 应用内文件预览
- C++ 编写一个选课系统
- Andriod之SHA-256,MD5加密字符串
- Android系统之路(初识MTK) ------ 内置三方apk到Rom可移动/可卸载
- 获取整机应用信息以及启动界面(通过adb启动应用)
- mysql-mysql优化
- 从头开始编写一个Orchard网上商店模块(1) - 介绍
- iOS高德定位和自带逆地理编码进行坐标转换
- 跟我一起写 Makefile(六)
- Python 对图片进行人脸识别
- 复选框的全选
- The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,c
- What are the differences between Apache Kafka and RabbitMQ?
- Egret)Demo - eui state自定义状态的使用
- linux grep 查找文件内容
- 跟我一起写 Makefile(五)
- COMODO防火墙专业版下载
- secureCRT
- jQuery全屏滚动插件fullPage.js
- CocoaPods制作