UITableView

UICollectionView

  //UICollectionViewLayout

//UICollectionViewLayout决定了UICollectionView如何显示在界面上,Apple提供了一个最简单的默认layout对象:UICollectionViewFlowLayout。

//Flow Layout是一个Cells的线性布局方案,并具有页面和页脚。其可定制的内容如下:

//itemSize属性

//设定全局的Cell尺寸,如果想要单独定义某个Cell的尺寸,可以使用下面方法:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;

//minimumLineSpacing属性

//设定全局的行间距,如果想要设定指定区内Cell的最小行距,可以使用下面方法:

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section;

//minimumInteritemSpacing属性

//设定全局的Cell间距,如果想要设定指定区内Cell的最小间距,可以使用下面方法:

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section;

//scrollDirection属性

//设定滚动方向,有UICollectionViewScrollDirectionVertical和UICollectionViewScrollDirectionHorizontal两个值。

//headerReferenceSize属性与footerReferenceSize属性

//设定页眉和页脚的全局尺寸,需要注意的是,根据滚动方向不同,header和footer的width和height中只有一个会起作用。如果要单独设置指定区内的页面和页脚尺寸,可以使用下面方法:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section;

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section;

//sectionInset属性

//设定全局的区内边距,如果想要设定指定区的内边距,可以使用下面方法:

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section;

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//UICollectionViewDataSource

//返回collection view里区(section)的个数,如果没有实现该方法,将默认返回1:

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView

//返回指定区(section)包含的数据源条目数(number of items),该方法必须实现:

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section

//返回某个indexPath对应的cell,该方法必须实现:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

{

UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"myCell" forIndexPath:indexPath];

if(indexPath.section==0)

{

cell.backgroundColor = [UIColor redColor];

}

else if(indexPath.section==1)

{

cell.backgroundColor = [UIColor greenColor];

}

return cell;

}

//UICollectionViewCell结构上相对比较简单,由下至上:

//

//首先是cell本身作为容器view

//然后是一个大小自动适应整个cell的backgroundView,用作cell平时的背景

//再其次是selectedBackgroundView,是cell被选中时的背景

//最后是一个contentView,自定义内容应被加在这个view上

//为collection view添加一个补充视图(页眉或页脚)

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath

//设定页眉的尺寸

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section

//设定页脚的尺寸

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section

//添加页眉和页脚以前需要注册类和标识:

- (void)registerClass:(Class)viewClass forSupplementaryViewOfKind:(NSString *)elementKind withReuseIdentifier:(NSString *)identifier

//设定指定区内Cell的最小行距,也可以直接设置UICollectionViewFlowLayout的minimumLineSpacing属性

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section

//设定指定区内Cell的最小间距,也可以直接设置UICollectionViewFlowLayout的minimumInteritemSpacing属性

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section;

//UICollectionViewDelegate

//当指定indexPath处的item被选择时触发

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath

//P.s. 当你删除或添加元素时,一定要更新numberOfItemsInSection的返回情况。

//当指定indexPath处的item被取消选择时触发,仅在允许多选时被调用

- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath

//下面是三个和高亮有关的方法:

//事件的处理顺序如下:

//

//手指按下

//shouldHighlightItemAtIndexPath (如果返回YES则向下执行,否则执行到这里为止)

//didHighlightItemAtIndexPath (高亮)

//手指松开

//didUnhighlightItemAtIndexPath (取消高亮)

//shouldSelectItemAtIndexPath (如果返回YES则向下执行,否则执行到这里为止)

//didSelectItemAtIndexPath (执行选择事件)

//如果只是简单实现点击后cell改变显示状态,只需要在cellForItemAtIndexPath方法里返回cell时,指定cell的selectedBackgroundView

- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath

- (void)collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath

- (void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath

复习知识点:UITableView和UICollectionView的常用属性的更多相关文章

  1. 12-27 UITableView常用属性及方法

    UITableView也有自己的代理协议,它本身继承自UIScrollView 一:代理要遵守代理协议<UITableViewDelegate>,代理协议中的代理方法: 1.改变某一行的行 ...

  2. UITableView的常用属性和cell的内存优化

    UITableView的常用属性: 分割线颜色设置: 1> 设置separatorStyle: 分割线的颜色 方法:tableView.separatorStyle = UITableViewC ...

  3. UITableView常用属性和方法 - 永不退缩的小白菜

    UITableView常用属性和方法 - 永不退缩的小白菜 时间 2014-05-27 01:21:00  博客园精华区原文  http://www.cnblogs.com/zhaofucheng11 ...

  4. JavaEE期末复习知识点总结

    JavaEE期末复习知识点总结 Java企业应用开发环境 Maven的基础概念 Maven是一个项目管理工具,可以对 Java 项目进行构建.依赖管理 Maven仓库 Maven 仓库是项目中依赖的第 ...

  5. RumTime实践之--UITableView和UICollectionView缺省页的实现

    有关RunTime的知识点已经看过很久了,但是一直苦于在项目中没有好的机会进行实际运用,俗话说"光说不练假把式",正好最近在项目中碰到一个UITableView和UICollect ...

  6. CSS样式常用属性整理

    web工程师是最近5年刚刚兴起的一门高薪职业,人们的专注度越来越高. 那么前端除了学习html标签之外还需要掌握什么知识点呢? 为大家整理了一个和HTML标签密不可分的知识要点--<CSS样式常 ...

  7. UITableView和UICollectionView的Cell高度的几种设置方式

    UITableViewCell 1.UITableView的Cell高度默认由rowHeight属性指定一个低优先级的隐式约束 2.XIB中可向UITableViewCell的contentView添 ...

  8. iOS 8自动调整UITableView和UICollectionView布局

    本文转载自:http://tech.techweb.com.cn/thread-635784-1-1.html 本文讲述了UITableView.UICollectionView实现 self-siz ...

  9. iOS中UITableView和UICollectionView的默认空态页

    项目中想实现空态页风格统一控制的效果,就封装了一个默认空态页,使用的技术点有:1 方法替换 ,2 给分类(Category)添加属性. 我们知道,扩展(extension)可以给类添加私有变量和方法. ...

随机推荐

  1. 七日筑基——C#第一天(下)

    继续C#第一天的内容,昨天我们简单说了一下如何用C#代码来让学生做自我介绍,介绍的格式要求:“我叫威震天,今年20岁,我喜欢踢足球和上网,希望接下来的三年能跟大家一起成长.”威震天介绍完了,继续下一个 ...

  2. SPOJ 7001 VLATTICE - Visible Lattice Points(莫比乌斯反演)

    题目链接:http://www.spoj.com/problems/VLATTICE/ 题意:求gcd(a, b, c) = 1    a,b,c <=N 的对数. 思路:我们令函数g(x)为g ...

  3. idea中使用sbt构建scala项目及依赖

    1.安装scala插件 http://www.cnblogs.com/yrqiang/p/5310700.html 2. 详细了解sbt: http://www.scala-sbt.org/0.13/ ...

  4. 自定义标签(TagSupport )

    转载:http://zhuhuide2004.iteye.com/blog/555737 这个图太好了,拿下来,标注一下:

  5. 如何修改Protel99SE原理图的标题栏

    本文主要讲述了如何修改Protel99SE原理图中的标题栏内容,使用者可以根据需要修改. 标题栏的格式: 1.添加模板:(1)菜单栏Design\Template\Set Template File ...

  6. Delphi的MDI编程中遇到的一个奇怪问题(值得研究的一个问题)

    近日在用delphi写一个多文档应用程序,除了一个主界面是自动生成的,其他功能页面全部都是通过Application.CreateForm()动态生成的,也就是说在ProjectManager中点击程 ...

  7. (C#)Windows Shell 外壳编程系列8 - 同后缀名不同图标?

    原文 (C#)Windows Shell 外壳编程系列8 - 同后缀名不同图标? (本系列文章由柠檬的(lc_mtt)原创,转载请注明出处,谢谢-) 接上一节:(C#)Windows Shell 外壳 ...

  8. nginx自定义模块记录上游服务器特定响应头

    功能,服务器通过扩展自定义命令,记录上游的服务器返回的特定响应头内容,记录到本地文件中 代码如下: /* * Copyright (C) Ciaos */ #include <ngx_confi ...

  9. xen虚拟机操作整理

    1,登陆物理机器 2,查看物理机建立虚拟机的列表 root:~ # xm li Name ID Mem VCPUs State Time(s) Domain-0 0 49450 8 r----- 52 ...

  10. 七、cocos2dx之粒子系统

    本文由qinning199原创,转载请注明:http://www.cocos2dx.net/?p=66 一.介绍 粒子系统指的是一个使用大量很小的精灵或者其他的一些绘制对象模拟一些模糊效果.使用传统的 ...