swift (3.3)UICollectionView 的 SectionHeader问题
来源:互联网 发布:excel怎样数据保护 编辑:程序博客网 时间:2024/06/05 06:02
(SectionHeaderView 不显示问题)
自己在写UICollectionView的时候 想设置SectionHeaderView的时候。怎么都不显示,layout 的布局也设置了,包括注册 sectionHeaderView
collectionView.register(YMCollectionHeaderView.self, forSupplementaryViewOfKind:UICollectionElementKindSectionHeader, withReuseIdentifier: reusedId) // section headerView 的高 layout.headerReferenceSize = CGSize(width: SCREENW, height: 100);
最后发现一个版本的问题 , 因为比较懒,代理方法直接是copy的,但是swift3.3 的代理方法已经稍微变化,导致网上的方法不走。
网上方法:
func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView { //判断如果 kind 是footerView类型 if kind == UICollectionElementKindSectionFooter { //创建footerView, 填写footerView类型(kind)、复用标识符、indexPath footerView = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: reusedId, forIndexPath: indexPath) //设置footerView背景颜色 footerView.backgroundColor = UIColor.redColor() return footerView } return footerView }
但是swift3.3 方法已经稍微不同,外部参数已经处理掉了
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { var reusableview:YMCollectionHeaderView! if kind == UICollectionElementKindSectionHeader { reusableview = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: reusedId, for: indexPath) as! YMCollectionHeaderView } else if kind == UICollectionElementKindSectionFooter { } return reusableview }
在根据自己的一些要求来处理sectionHeaderView。
———–代码还是用心的好。
-谨记
阅读全文
0 0
- swift (3.3)UICollectionView 的 SectionHeader问题
- UICollectionview实现类似UITableview的sectionheader悬浮代码
- iOS - Swift UICollectionView横向分页的问题
- swift UICollectionView的使用
- [Swift 开发] UICollectionView的用法
- UICollectionView的横线问题
- Swift实现最简单的UICollectionView
- UITableview Plain风格下 SectionHeader悬浮问题
- UICollectionView重用机制的问题
- UICollectionView的下拉刷新问题
- UICollectionView的cell间距问题
- 设置tableView的sectionheader的高度
- IOS SWIFT---使用UICollectionView
- Swift自定义UITableView、UICollectionView
- swift 之 UICollectionView
- Swift UICollectionView 使用
- 【Swift】iOS UICollectionView 计算 Cell 大小的陷阱
- iOS开发Swift UITableView和UICollectionView的使用
- 控制单据表体的【列名】变化
- Flex 弹性布局使用及说明
- 69. Sqrt(x)
- Linux安装tomcat
- 【Mybatis】Helloworld
- swift (3.3)UICollectionView 的 SectionHeader问题
- npm --save 和 npm --save -dev的区别
- Base64编码实现二---使用org.apache.tomcat.util.codec.binary.Base64实现Base64
- 生活中与现实中的字体应用体验俯拾皆是...
- Java关键字transient和volatile
- JPG文件结构分析
- 表体某个页签的字段名字怎么动态改变
- Linux下nfs+rpcbind实现服务器之间的文件共享(mount 挂载)
- 对ThreadLocal实现原理的一点思考