问题点:
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