• 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 }
    }
  • 相关阅读:
    高手详解:sscanf函数的高级用法
    堆排序——BuildHeap和Heapify函数的实现
    递归与动态规划求解最长公共子序列
    分享:crpcut 1.8.4 发布,C++ 的单元测试框架
    团队展示 京拍档 电商运营服务、电子商务服务外包 首家京东代运营电子商务服务平台
    Linux中link,unlink,close,fclose详解
    常用排序算法的c++实现(冒泡,选择,插入,堆,shell,快速,归并 )与sort()对比 coder_xia的专栏 博客频道 CSDN.NET
    CAJ文件转PDF文件方法
    递归与动态规划求解最长公共子序列
    NLP Job 专注自然语言处理&机器学习等领域的求职招聘 | 关注自然语言处理|机器学习|数据挖掘|搜索引擎|计算广告|推荐算法等相关领域的工作机会
  • 原文地址:https://www.cnblogs.com/qzp2014/p/4274053.html
Copyright © 2020-2023  润新知