UICollectionView的常用方法
class UICollectionView : UIScrollView
//初始化,位置,风格
init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) //布局风格
var collectionViewLayout: UICollectionViewLayout
//代理
unowned(unsafe) var delegate: UICollectionViewDelegate?
//数据源
unowned(unsafe) var dataSource: UICollectionViewDataSource?
//背景视图
var backgroundView: UIView?
//注册cell
func registerClass(cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String)
func registerNib(nib: UINib?, forCellWithReuseIdentifier identifier: String)
func registerClass(viewClass: AnyClass?, forSupplementaryViewOfKind elementKind: String, withReuseIdentifier identifier: String)
func registerNib(nib: UINib?, forSupplementaryViewOfKind kind: String, withReuseIdentifier identifier: String)
func dequeueReusableCellWithReuseIdentifier(identifier: String, forIndexPath indexPath: NSIndexPath!) -> AnyObject
func dequeueReusableSupplementaryViewOfKind(elementKind: String, withReuseIdentifier identifier: String, forIndexPath indexPath: NSIndexPath!) -> AnyObject
var allowsSelection: Bool // default is YES
var allowsMultipleSelection: Bool // default is NO
//返回被选中的items
func indexPathsForSelectedItems() -> [AnyObject] // returns nil or an array of selected index paths
//选中弄个indexpath, 是否有动画,
func selectItemAtIndexPath(indexPath: NSIndexPath?, animated: Bool, scrollPosition: UICollectionViewScrollPosition)
//取消选中
func deselectItemAtIndexPath(indexPath: NSIndexPath?, animated: Bool)
//刷新数据
func reloadData()
func setCollectionViewLayout(layout: UICollectionViewLayout, animated: Bool)
func setCollectionViewLayout(layout: UICollectionViewLayout, animated: Bool)
@availability(iOS, introduced=7.0)
func setCollectionViewLayout(layout: UICollectionViewLayout, animated: Bool, completion: ((Bool) -> Void)!)
@availability(iOS, introduced=7.0)
func startInteractiveTransitionToCollectionViewLayout(layout: UICollectionViewLayout, completion: UICollectionViewLayoutInteractiveTransitionCompletion?) -> UICollectionViewTransitionLayout
@availability(iOS, introduced=7.0)
func finishInteractiveTransition()
@availability(iOS, introduced=7.0)
func cancelInteractiveTransition()
//有几个
func numberOfSections() -> Int
//每个有多少行
func numberOfItemsInSection(section: Int) -> Int
func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes?
func layoutAttributesForSupplementaryElementOfKind(kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes?
func indexPathForItemAtPoint(point: CGPoint) -> NSIndexPath?
func indexPathForCell(cell: UICollectionViewCell) -> NSIndexPath?
func cellForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewCell?
func visibleCells() -> [AnyObject]
func indexPathsForVisibleItems() -> [AnyObject]
//滚动到indespath位置
func scrollToItemAtIndexPath(indexPath: NSIndexPath, atScrollPosition scrollPosition: UICollectionViewScrollPosition, animated: Bool)
//插入
func insertSections(sections: NSIndexSet)
//删除
func deleteSections(sections: NSIndexSet)
//重载弄个
func reloadSections(sections: NSIndexSet)
//移动
func moveSection(section: Int, toSection newSection: Int)
func performBatchUpdates(updates: (() -> Void)?, completion: ((Bool) -> Void)?)
extension NSIndexPath {
init!(forItem item: Int, inSection section: Int) -> NSIndexPath
@availability(iOS, introduced=6.0)
var item: Int { get }
}
UICollectionView的常用方法的更多相关文章
- iOS开发- UICollectionView详解+实例
本章通过先总体介绍UICollectionView及其常用方法,再结合一个实例,了解如何使用UICollectionView. UICollectionView 和 UICollectionViewC ...
- iOS开发——UI篇OC篇&UICollectionView详解+实例
UICollectionView详解+实例 实现步骤: 一.新建两个类 1.继承自UIScrollView的子类,比如HMWaterflowView * 瀑布流显示控件,用来显示所有的瀑布流数据 2. ...
- [转] iOS开发- UICollectionView详解+实例
本章通过先总体介绍UICollectionView及其常用方法,再结合一个实例,了解如何使用UICollectionView. UICollectionView 和 UICollectionViewC ...
- iOS-UICollectionView
1--------------------------------------------------------------------------------------------------- ...
- iOS-UICollectionView的简单使用(原创)
前言 UICollectionView是一种新的数据展示方式,简单来说可以把他理解成多列的UITableView(请一定注意这是UICollectionView的最最简单的形式).如果你用过iBook ...
- iOS UICollectionView简单使用
UICollectionView 和 UICollectionViewController 类是iOS6 新引进的API,用于展示集合视图,布局更加灵活,可实现多列布局,用法类似于UITableVie ...
- iOS流布局UICollectionView使用FlowLayout进行更灵活布局
一.引言 前面的博客介绍了UICollectionView的相关方法和其协议中的方法,但对布局的管理类UICollectionViewFlowLayout没有着重探讨,这篇博客介绍关于布局的相关设置和 ...
- iOS UI-集合视图(UICollectionView)
BowenCollectionViewCell.xib #import <UIKit/UIKit.h> @interface BowenCollectionViewCell : UICol ...
- UICollectionView的简单认识和简单实用
摘要 UICollectionView是比UITableView更加复杂的UI控件,通过它可以实现许多复杂的流布局.但对我们来说,系统提供的接口十分简单易用,并且有十分强的制定性. iOS流布局UIC ...
随机推荐
- web服务器上某一中文名文件无法访问
只需要在此目录下 convmv -f GBK -t UTF-8 --notest *.xxx 执行这个命令即可
- C++类的继承中构造函数和析构函数调用顺序例子
/*当建立一个对象时,首先调用基类的构造函数,然后调用下一个派生类的构造函数,依次类推,直至到达派生类次数最多的派生次数最多的类的构造函数为止.简而言之,对象是由“底层向上”开始构造的.因为,构造函数 ...
- ifconfig相关参数及用法说明
一.ifconfig ifconfig 主要是可以手动启动.观察与修改网络接口的相关参数,可以修改的参数很多,包括 IP 参数以及 MTU 等都可以修改,它的语法如下: [root@linux ~]# ...
- 深度神经网络(DNN)是否模拟了人类大脑皮层结构?
原文地址:https://www.zhihu.com/question/59800121/answer/184888043 神经元 在深度学习领域,神经元是最底层的单元,如果用感知机的模型, wx + ...
- 1.ROS启动小乌龟
启动turtlesim 在三个不同的终端中分别执行如下三个指令 roscore rosrun turtlesim turtlesim_node rosrun turtlesim turtle_ ...
- VC++ 错误
1.error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup解决方 ...
- CodeVs 3150 (大数 + 递推)
#include<iostream> #include<cstdio> #include<cstring> #include<string> #incl ...
- Linux命令之chmod、chown
一.chmod命令 chmod命令用于改变linux系统文件或目录的访问权限.用它控制文件或目录的访问权限.该命令有两种用法.一种是包含字母和操作符表达式的文字设定法:另一种是包含数字的数字设定法. ...
- 前端 ----- 01 -html介绍和head标签
01-html介绍和head标签 主要内容 web标准 浏览器介绍 开发工具介绍 HTML介绍 HTML颜色介绍 HTML规范 HTML结构详解 一.web标准 web准备介绍: w3c:万维网联 ...
- 【原创】大数据基础之Marathon(2)marathon-lb
marathon-lb 官方:https://github.com/mesosphere/marathon-lb 一 简介 Marathon load balancer (Marathon-LB) i ...