美文网首页
CollectionView代理方法的介绍

CollectionView代理方法的介绍

作者: 萨瓦迪卡123456 | 来源:发表于2016-11-17 11:12 被阅读54次

    1.这个方法和tableview的一样,返回的是collection中item的个数。

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

    2.返回的collection有多少个区

    - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView;

    3.配置cell,同时也需要注册cell

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

    4.这个方法是反回cell是否可以拖拽移动,但是他需要给collection添加长按手势的操作

    - (void)collectionView:(UICollectionView *)collectionView moveItemAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath*)destinationIndexPath NS_AVAILABLE_IOS(9_0);

    5.这个方法可以自定义collection的headerview和footview,同时呢,我们需要先进行注册

    - (__kindof UICollectionReusableView *)dequeueReusableSupplementaryViewOfKind:(NSString *)elementKind withReuseIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath;

    6.当cell即将显示的时候调用的方法

    - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(8_0);

    以上这些方法就是最基本的方法。

    相关文章

      网友评论

          本文标题:CollectionView代理方法的介绍

          本文链接:https://www.haomeiwen.com/subject/bhsdpttx.html