ios – UICollectionView标题视图没有正确出列
发布时间:2020-12-14 17:32:58 所属栏目:百科 来源:网络整理
导读:我正在尝试向集合视图添加标头.我正在使用水平滚动的自定义布局,它用于查看朋友的头像图像列表.我可以让标题出现,但它不会出列.一旦标题视图离开屏幕,它就会消失.任何人都可以弄清楚这是为什么? 谢谢! 集合查看数据源: - (UICollectionReusableView *)col
我正在尝试向集合视图添加标头.我正在使用水平滚动的自定义布局,它用于查看朋友的头像图像列表.我可以让标题出现,但它不会出列.一旦标题视图离开屏幕,它就会消失.任何人都可以弄清楚这是为什么?
谢谢! 集合查看数据源: - (UICollectionReusableView *)collectionView:(SWAvatarViewerCollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { if (self.showAddAvatarHeaderView && [kind isEqualToString:UICollectionElementKindSectionHeader]) { return [collectionView dequeueAddAvatarViewHeaderForIndexPath:indexPath]; } return nil; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(SWAvatarViewerCollectionViewFlowLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section { if (!self.showAddAvatarHeaderView) { return CGSizeZero; } return CGSizeMake(kSWAvatarViewerAddAvatarHeaderViewWidth,CGRectGetHeight(collectionView.bounds)); } 头像集合视图: - (SWAvatarViewerAddAvatarHeaderView *)dequeueAddAvatarViewHeaderForIndexPath:(NSIndexPath *)indexPath { SWAvatarViewerAddAvatarHeaderView *headerView = [super dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:[SWAvatarViewerAddAvatarHeaderView headerReuseIdentifier] forIndexPath:indexPath]; headerView.delegate = self; return headerView; } Nib文件注册: [self registerNib:[SWAvatarViewerAddAvatarHeaderView nib] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:[SWAvatarViewerAddAvatarHeaderView headerReuseIdentifier]]; 布局: #pragma mark - Initialization - (void)configureFlowLayout { self.scrollDirection = UICollectionViewScrollDirectionHorizontal; // Padding for cells is taken into account in the cell's layout. Remove all // padding between cells self.sectionInset = UIEdgeInsetsMake(0,00.0f,00.0f); self.minimumLineSpacing = 0.0f; self.minimumInteritemSpacing = CGFLOAT_MAX; _cellBottomLabelFont = [UIFont systemFontOfSize:12.0]; CGSize defaultAvatarSize = CGSizeMake(44.0f,44.0f); _avatarViewSize = defaultAvatarSize; _springinessEnabled = YES; _springResistanceFactor = 1000; } 解决方法
你显然使用的是我从未听说过的第三方布局.在与你讨论之后,我的感觉是我在你的问题下的第一个评论可能是正确的:布局本身可能是错误的.
在集合视图中,单元格的布局属性(位置,大小,变换,alpha等)是布局的责任.因此,如果某些东西仅仅因为它从屏幕上滚动然后重新开启而消失,那么听起来布局本身并没有正确地完成其工作. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |