zoukankan      html  css  js  c++  java
  • UICollectionview的头视图和尾视图

    UITableView有头视图和尾视图,那么UICollectionView有没有头视图和尾视图呢?

    答案是有的.

    1.新建一个类,必须继承自 UICollectionReusableView.

    2.需要实现UIcollectionViewDataSource中的方法:viewForSupplementaryElementOfKind;

     1 - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
     2 
     3     UICollectionReusableView *reusableView = nil;
     4 
     5     if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
     6 
     7         HLTopicItemHeader * header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kTopicHeaderIdentifier forIndexPath:indexPath];
     8 
     9         //有缓存了
    10         [header.imgV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kDataServer2,_topic_img_url]] placeholderImage:[UIImage imageNamed:@"AppIcon60x60@3x"]];
    11 
    12         header.title.text = _topic_title;
    13         reusableView = header;
    14     }
    15 
    16     return reusableView;
    17 }

    今天才知道UICollectionView原来还有头视图和尾视图呀...嘿嘿!!!

  • 相关阅读:
    Feature fake , new view in comment.
    MeeGo Architect
    小米手机 怪诞行为经济学
    [转载]ten years as a programmer
    C++ 头文件
    关于AGILE/TDD 和传统的design
    你是否在开发正确的产品
    正确的创业
    MeeGo架构
    Unit Test
  • 原文地址:https://www.cnblogs.com/pengsi/p/5336593.html
Copyright © 2011-2022 走看看