zoukankan      html  css  js  c++  java
  • 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 }
    }
  • 相关阅读:
    《Java并发编程的艺术》 第9章 Java中的线程池
    《Java并发编程的艺术》第6/7/8章 Java并发容器与框架/13个原子操作/并发工具类
    java锁总结
    《Java并发编程的艺术》第5章 Java中的锁 ——学习笔记
    《Java并发编程的艺术》第4章 Java并发编程基础 ——学习笔记
    Java并发编程的艺术(一、二章) ——学习笔记
    redis缓存使用SpringDataRedis
    商城06——solr索引库搭建&solr搜索功能实现&图片显示问题解决
    商城05——首页轮播图显示实现&Redis环境搭建&Redis实现缓存
    商城04——门户网站介绍&商城首页搭建&内容系统创建&CMS实现
  • 原文地址:https://www.cnblogs.com/qzp2014/p/4274053.html
Copyright © 2011-2022 走看看