开发者社区 问答 正文

如何给collectionView添加表头?

如题,我想给collectionView每个分区都添加一个表头,像tableView一样。经过查询得知需要实现这个代理

  • (UICollectionReusableView )collectionView:(UICollectionView )collectionView viewForSupplementaryElementOfKind:(NSString )kind atIndexPath:(NSIndexPath )indexPath

但是我实现这个方法之后这个方法不执行,不知道是什么原因,代理我已经设置了

collection.delegate = self;

collection.dataSource = self;

展开
收起
杨冬芳 2016-06-24 16:29:18 3323 分享 版权
1 条回答
写回答
取消 提交回答
  • IT从业

    collectionView 表头的代理跟tableview 不一样的代理方式

    • (UICollectionReusableView )collectionView:(UICollectionView )collectionView viewForSupplementaryElementOfKind:(NSString )kind atIndexPath:(NSIndexPath )indexPath;
    2019-07-17 19:47:07
    赞同 展开评论
问答地址: