首页 > 其他 > 详细

UICollectionView的常用方法

时间:2015-02-05 11:10:36      阅读:892      评论:0      收藏:0      [点我收藏+]
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

 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的常用方法

原文:http://www.cnblogs.com/qzp2014/p/4274053.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!