LTTemplateLayoutItem icon indicating copy to clipboard operation
LTTemplateLayoutItem copied to clipboard

支持头部视图拓展后,Cell高度出现不太准确的问题

Open ETmanwenhan opened this issue 7 years ago • 0 comments

  • (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { [self initCellYArray]; NSMutableArray *array = [NSMutableArray array]; for (NSInteger i = 0; i < _indexCountBySectionForHeight.count; i++) {

      //SectionHeader
      UICollectionViewLayoutAttributes *attributesHeader = [self layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionHeader atIndexPath:[NSIndexPath indexPathForRow:0 inSection:i]];
      [array addObject:attributesHeader];
    
      for (NSInteger j = 0; j < _indexCountBySectionForHeight[i].count; j++) {
          NSIndexPath *indexPath = [NSIndexPath indexPathForItem:j inSection:i];
          UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForItemAtIndexPath:indexPath];
          [array addObject:attributes];
    
      }
    

    } return array; }

  • (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath { CGFloat height = [self maxCellYArrayWithArray:_cellYArray]; [self resetCellYArray:height]; UICollectionViewLayoutAttributes *attribute = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:elementKind withIndexPath:indexPath]; attribute.frame = CGRectMake(0, height, self.headerReferenceSize.width, self.headerReferenceSize.height); return attribute; }

ETmanwenhan avatar Aug 18 '17 02:08 ETmanwenhan