pandaXiongV 2015-03-13 08:04 采纳率: 0%
浏览 15620

IOS中uicollectionview有没有headerview

tableview有tableheaderview,uicollectionview有没有与之相似的"cllection headerview"?我知道uicollectionview可以设置每个分组的页眉页脚,但没找到整个uicollectionview上面的headerView,上面要加个轮播图。

  • 写回答

5条回答

  • 白马斩辰 2015-03-19 13:47
    关注

    UICollectionView作为比UITableView更强大的封装,自然是有header和footer的。
    UICollectionView有一个delegate,

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

    这个方法中可以生成一个UICollectionReusableView,顾名思义是一个可重用的view,与UITableView中重用cell的意思一样。
    这个UICollectionReusableView有两种不同类型,分别是UICollectionElementKindSectionHeader和UICollectionElementKindSectionFooter,这就是你要找的header和footer了。

    一个UICollectionReusableView的生成例子如下

    UICollectionReusableView *view = [_collectionView
    dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter
    withReuseIdentifier:TheReuseID
    forIndexPath:indexPath];

    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办