Learning iOS D8 2017-10-31

学习UICollectionView

1.添加uicollectionview

完成配置

tips:

定义collectionview时需要初始化collectionview的布局 因此事先需要对layout进行配置

collectionview与tableview不同,tableview只需要对cell进行register,而collectionview需要对cell header footer进行register 这里register的方法也有细小的区别forCellReuseIdentifier 与 forCellWithReuseIdentifier

register footer/header 时 register(UICollectionReusableView.self, forSupplementaryViewOfKind:UICollectionElementKindSectionHeader, withReuseIdentifier: UICollectionElementKindSectionHeader)    蓝色的UICollectionElementKindSectionHeader 是string类型

2.对header/footer进行设置

extension 该vc 导入UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout  ,UICollectionViewDelegateFlowLayout是控制布局的方法 返回CGSize

方法viewForSupplementaryElementOfKind用来对header/footer进行设置

UICollectionViewDelegate, UICollectionViewDataSource这两个的用法与tableview相同

3.对不同cell的处理

tag属性 相当于吧cell的index.row提了出来 方便在其他方法也能调用到tag

明日目标:继续把这个页面做完,包括tapp方法的实现

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容