uicollectionreusableview

Removing empty space, if the section header is hidden in the UICollectionView

£可爱£侵袭症+ 提交于 2019-11-27 10:44:35
问题 I have two sections in UICollectionView . I want to show a section header in UICollectionView for only 1st section. Not in 0th section. So I tried to return nil in viewForSupplementaryElementOfKind : method for section == 0 and returns view for the section == 1 . It crashes and shows below error: Assertion failure in -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes]: Here it is my code for the supplementary view. -

Add a simple UIView as header of UICollectionView

走远了吗. 提交于 2019-11-27 03:44:03
问题 I have a UICollectionView . I would like to add a header. My header would only be a UILabel . I've : 1) selected "Section Header" as a Collection View accessory in the IB. 2) created a Collection Reusable View in the IB, on the side, declared as collectionViewHeader . 3) added those lines : - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { if (kind ==