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 ...
随机推荐
- ECMAScript5下Array的方法
声明:ECMAScript不会兼容IE8及以下版本IE浏览器. 一.迭代方法 注:这些迭代方法不会影响数组的值. 每个方法都有两个参数: array.方法(执行函数体,当前作用域(比如this,这个可 ...
- LA 3350
The NASA Space Center, Houston, is less than 200 miles from San Antonio, Texas (the site of the ACM ...
- netaddr 0.7.12
Pythonic manipulation of IPv4, IPv6, CIDR, EUI and MAC network addresses https://pypi.python.org/pyp ...
- php curl 分离header和body信息
php中可以通过curl来模拟http请求,同时可以获取http response header和body,当然也设置参数可以只获取其中的某一个.当设置同时获取response header和body ...
- spring_150804_controller
实体类: package com.spring.model; public class DogPet { private int id; private String name; private in ...
- postgresql数据库的yum安装方法
实验环境>>>>>>>>>>>>>>>>>>操作系统:CentOS release 6.3 ...
- 李洪强iOS开发之后使用纯代码实现横向滚动的UIScrollView
李洪强iOS开发之后使用纯代码实现横向滚动的UIScrollView (VTmagic是一个实现左右滚动的控制器的框架,也可以实现此功能) 实现的效果: 01 - 创建四个控制器 02 - 定义需要 ...
- hdu 3389 Game (阶梯博弈)
#include<stdio.h> int main() { int t,n,ans; int i,j,x; scanf("%d",&t); ;j<=t; ...
- CentOS系统安装tomcat
按照以下步骤操作即可wget http://mirrors.noc.im/apache/tomcat/tomcat-9/v9.0.0.M6/bin/apache-tomcat-9.0.0.M6.tar ...
- Java学习笔记之:Java 流
一.介绍 Java.io包几乎包含了所有操作输入.输出需要的类.所有这些流类代表了输入源和输出目标. Java.io包中的流支持很多种格式,比如:基本类型.对象.本地化字符集等等. 一个流可以理解为一 ...