UICollectionView
2015-10-14 18:06
363 查看
将 UICollectionView 的一些常用的方法和属性搞了一下
UICollectionView 和 UITableView 用法差不多也是继承UIScrollView 的
UICollectionView 和 UITableView 用法差不多也是继承UIScrollView 的
1.常用的方法: // 根据尺寸和布局方法来创建一个 UICollectionView - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout; // 根据代码注册 UICollectionViewCell的类型 - (void)registerClass:(Class)cellClass forCellWithReuseIdentifier:(NSString *)identifier; - (void)registerNib:(UINib *)nib forCellWithReuseIdentifier:(NSString *)identifier; // 注册 footerView 和 HeaderView 的 - (void)registerClass:(Class)viewClass forSupplementaryViewOfKind:(NSString *)elementKind withReuseIdentifier:(NSString *)identifier; - (void)registerNib:(UINib *)nib forSupplementaryViewOfKind:(NSString *)kind withReuseIdentifier:(NSString *)identifier; // 从缓冲池中取出 Cell 和头部尾部 View - (id)dequeueReusableCellWithReuseIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath*)indexPath; - (id)dequeueReusableSupplementaryViewOfKind:(NSString*)elementKind withReuseIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath*)indexPath; // 设置 UICollectionView 的布局方式 - (void)setCollectionViewLayout:(UICollectionViewLayout *)layout animated:(BOOL)animated; 2.属性 // cell 是否能被点击 @property (nonatomic) BOOL allowsSelection; // default is YES // cell 是否支持多点 @property (nonatomic) BOOL allowsMultipleSelection; // default is NO 3.UICollectionViewDataSource 数据源 // 多少组 - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView; // 每组多少个 cell - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section; // 返回 cell - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath; // 返回 头部和尾部的 view - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath; 4.UICollectionViewDelegate代理方法 // 选中单元格 cell - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath; UICollectionViewFlowLayout瀑布流布局 1.属性 scrollDirection // 滚动方向 minimumInteritemSpacing // 水平最小间距 minimumLineSpacing // 垂直最小间距 2.UICollectionViewDelegateFlowLayout继承 UICollectionViewDelegate代理方法 // 单元格的大小 - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ } //cell与cell之间的间隔,边距 - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ } //设置标题头大小 - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{ } //设置标题尾大小 - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{ }
相关文章推荐
- FineUI开源版之TreeGrid实现
- iOS 手写代码UICollectionView
- IOS 开发学习(3): IOS UI架构设计
- UICollectionView的下拉刷新问题
- UESTC 1712 Easy Problem With Numbers (线段树区间修改+非互素逆元)
- UIMenuController使用
- The resource identified by this request is only capable of generating responses with characteristics
- 给UIImageview 添加边框或者设置成圆角
- CALayer与UIView的关系
- UICollectionView详解 +实例
- Ant 打包war 生成文件内容build.xml
- UITableView刷新数据reLoadData
- iOS-UIKit(UIWindow.h--解读)
- easyUI相关知识
- UITableView小知识点总结
- Android AlertDialog.Builder详解
- iOS开发UI篇—UITabBarController简单介绍
- iOS截屏分享二维码(UIView)
- 继续使用Win10过期版本(build 10240之前的版本) 或有什么后果?
- UE3 预计算可见性