IOS中UICollectionView和UICollectionViewController的用法
1.新建一个xib描述UICollectionViewCell(比如DealCell.xib),设置好resuse identifier(比如deal)
2.控制器继承UICollectionViewController
1> 注册xib
[self.collectionView registerNib:[UINib nibWithNibName:@"DealCell" bundle:nil] forCellWithReuseIdentifier:@"deal"];
2> 重写init方法
- (id)init
{
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
// 每一个网格的尺寸
layout.itemSize = CGSizeMake(250, 250);
// 每一行之间的间距
layout.minimumLineSpacing = 20;
// 上下左右的间距
layout.sectionInset = UIEdgeInsetsMake(10, 20, 40, 80); return [self initWithCollectionViewLayout:layout];
}
3> 实现数据源方法
#pragma mark 每一组有多少个条目(格子)
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
#pragma mark 每一个格子显示什么样的cell
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
3.UICollectionViewFlowLayout的常见设置
1> CGFloat minimumLineSpacing:每一行之间的间距
2> UIEdgeInsets sectionInset:上下左右周边的间距
3> CGSize itemSize:每一个网格的大小
4.UICollectionView的设置
1> BOOL alwaysBounceVertical:永远支持垂直的弹簧效果(滚动效果,来自UIScrollView的属性)
5.UITableViewController和UICollectionViewController的区别
1> 在UITableViewController中:self.tableView == self.view
2> 在UICollectionViewController中:self.collectionView == self.view中的一个子控件
IOS中UICollectionView和UICollectionViewController的用法的更多相关文章
- iOS中Realm数据库的基本用法
原文 http://git.devzeng.com/blog/simple-usage-of-realm-in-ios.html 主题 RealmiOS开发 Realm是由 Y Combinat ...
- ios中UIWebview和asiHttprequest的用法
原文地址为:http://www.cnblogs.com/pengyingh/articles/2343062.htmlasiHttprequest的用法 它对Get请求的响应数据进行缓存(被缓存的数 ...
- iOS中UIButton控件的用法及部分参数解释
在UI控件中UIButton是极其常用的一类控件,它的类对象创建与大多数UI控件使用实例方法init创建不同,通常使用类方法创建: + (id)buttonWithType:(UIButtonType ...
- iOS中的translucent和automaticallyAdjustsScrollViewInsets用法
关于这两个属性我长话短说 具体的可以更具具体情况来设置: translucent用法 automaticallyAdjustsScrollViewInsets用法 translucent用法 iOS7 ...
- ios中get,post和解压缩用法
一. 网络概念 1. 在Linux系统上,运行的Web服务器的名字叫做Apache 2. 所有的http访问都是基于html或者相关的文件,例如:php,asp,jsp,asp.net 这些文件最终都 ...
- iOS中 UICollectionView UI_19
UICollectionView 是UITableView加强版 UITableView 和UICollectionView的设计思想: 1.布局: UITableView 的布局可以由UITable ...
- iOS中UICollectionView添加头视图
参考链接:https://www.jianshu.com/p/ef57199bf34a 找了一堆的博客,写的都少了很重要的一步. //引入头部视图 -(UICollectionReusableView ...
- iOS 中UICollectionView实现各种视觉效果
参考链接:https://www.jianshu.com/p/b3322f41e84c 基础:https://www.jianshu.com/p/d0b034f59020
- iOS开发之窥探UICollectionViewController(三) --使用UICollectionView自定义瀑布流
上篇博客的实例是自带的UICollectionViewDelegateFlowLayout布局基础上来做的Demo, 详情请看<iOS开发之窥探UICollectionViewControlle ...
随机推荐
- Sublime Text 编辑器
1.从http://www.sublimetext.com/2 下载Sublime Text 2编辑器. 2.安装Package Control 管理器,用于管理和安装插件包. 下载地址:https: ...
- 刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 3(Sorting/Searching)
第一题:340 - Master-Mind Hints UVA:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Item ...
- sqoop导入hdfs上的数据到oracle
/opt/sqoop-/bin/sqoop export --table mytablename --connect jdbc:oracle:thin:@**.**.**.**:***:dbasena ...
- [转载] poll()函数
原地址:http://baike.baidu.com/view/2997591.htm poll()函数:这个函数是某些Unix系统提供的用于执行与select()函数同等功能的函数,下面是这个函 ...
- 理解Node.js事件驱动编程
Node.js现在非常活跃,相关生态社区已经超过Lua(基本上比较知名的功能都有nodejs模块实现). 但是我们为何要使用Node.Js?相比传统的webserver服务模式,nodejs有什么优点 ...
- interviewbit :Min Steps in Infinite GridBookmark Suggest Edit
You are in an infinite 2D grid where you can move in any of the 8 directions : (x,y) to (x+1, y), (x ...
- Ajax实例-购物车
一.概述 1.当添加或删除商品时,购物车会立即更新数据 2.思路: (1)建立商品类Item.java,存有商品属性name,prince,code(商品编码)等 (2)建立商品目录类Catalog. ...
- 阿里云centos6搭建vpn
下载脚本 wget http://latrell.me/wp-content/uploads/vpn_centos6.sh 运行脚本 chmod a+x vpn_centos6.sh ./vpn_ce ...
- MySql对空间数据库的支持
地址: MySQL5.1中文在线API:http://doc.mysql.cn/mysql5/refman-5.1-zh.html-chapter/spatial-extensions-in-mysq ...
- SPOJ 274 Johnny and the Watermelon Plantation(TLE)
O(n^3)的时间复杂度,改了半天交了二三十遍,TLE到死,实在没办法了…… 跪求指点!!! #include <cstdio> #include <cstdlib> #inc ...