UICollectionView
2016-01-13 10:23
555 查看
创建
// 先创建瀑布流(官方的) UICollectionViewFlowLayout *layOut = [[UICollectionViewFlowLayout alloc] init]; // 对每一个用来显示的区域称为item,就是tableView上的cell // 设置一下item的尺寸 layOut.itemSize = CGSizeMake(100, 160); // 设置最小行间距(横向滑动时无用) layOut.minimumLineSpacing = 15; // 最小列间距(纵向滑动时无用) layOut.minimumInteritemSpacing = 1; // 设置距离屏幕上下左右的间距 layOut.sectionInset = UIEdgeInsetsMake(10, 10, 0, 10); // 滑动方向 (枚举) layOut.scrollDirection = UICollectionViewScrollDirectionHorizontal; // 设置flowlayout头部滚动范围 layOut.headerReferenceSize = CGSizeMake(0, 300); // 创建collectionView UICollectionView *collection = [[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:layOut]; [self.view addSubview:collection]; collection.dataSource = self; collection.backgroundColor = [UIColor whiteColor]; // 注册:类似于tableView [collection registerClass:[MyCollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
协议方法实现与tableView基本相同
自定义cell与tableView基本相同
相关文章推荐
- 学习笔记之-------UIScrollView 基本用法 代理使用
- 关于创建pch文件后,导入文件出现could not build module foundation错误提示
- 《iOS Human Interface Guidelines》——Social Media
- Access restriction : The type BASE64Decoder is not accessible due to restriction
- android requestLayout的流程介绍
- [iOS学习]UISegmentControl的无边框形式如何设置
- G面经Prepare: Search word delete sequence in dictionary
- iOS UITableView(十三) tableView经常用的代理总结和滑动删除
- 8937 build tz file
- 循环中continue和break的区别
- 【FAQ】xcodebuild 签名,提示User interaction is not allowed?
- 于UIImage图片处理详细使用
- iOS UIFont 字体名字大全
- django migrate raise ValueError('The database backend does not accept 0 as a '
- JUI 添加或修改后不自动刷新是怎么回事?
- 键盘和输入框上移
- Data Binding Guide——google官方文档翻译(上)
- 解决build path contains duplicate entry:'src' for project 'XXX'问题
- *Implement Stack using Queues
- js中innerText,value,innerHTML的区别