前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CollectionView stortBoard headview bug

CollectionView stortBoard headview bug

作者头像
星宇大前端
发布2019-01-15 10:45:02
4150
发布2019-01-15 10:45:02
举报
文章被收录于专栏:大宇笔记大宇笔记

问题点:

1.不显示问题 

2.拖不出xib上的控件做属性 报错信息如下: outlets connot  be connected to repeating content

原因及解决办法:

1.因为collectionView的headerView也有复用机制,所以需要实现复用代理方法

解决如下:

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

UICollectionReusableView *reusableview =nil;

UICollectionReusableView *headerView = [collectionViewdequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeaderwithReuseIdentifier:@"header"forIndexPath:indexPath];

    reusableview = headerView;

return reusableview;

}

提示:不要忘记在xib或者storyBoard上给headerView加复用标志

2.正因为复用所以你拖出的属性控件是从复的,不能确定唯一性。

解决办法如下:

    在xib或storyBoard给控件加上一个tag,在上面那个方法上取一下。

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

UICollectionReusableView *reusableview =nil;

UICollectionReusableView *headerView = [collectionViewdequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeaderwithReuseIdentifier:@"header"forIndexPath:indexPath];

_adScrowView  =  [headerViewviewWithTag:1234];

_adScrowView.delegate  =self;

if (_bannerData>0) {

        [selfinitAdView];

    }

return reusableview;

}

最后的成品,上面是headView

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016年11月23日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档