`minimumColumnSpacing` is ambiguous in Swift and Objective-C version
HY558 opened this issue · 0 comments
HY558 commented
Objective-C:
- (CGFloat)itemWidthInSectionAtIndex:(NSInteger)section {
UIEdgeInsets sectionInset;
if ([self.delegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)]) {
sectionInset = [self.delegate collectionView:self.collectionView layout:self insetForSectionAtIndex:section];
} else {
sectionInset = self.sectionInset;
}
CGFloat width = self.collectionView.bounds.size.width - sectionInset.left - sectionInset.right;
NSInteger columnCount = [self columnCountForSection:section];
CGFloat columnSpacing = self.minimumColumnSpacing;
if ([self.delegate respondsToSelector:@selector(collectionView:layout:minimumColumnSpacingForSectionAtIndex:)]) {
columnSpacing = [self.delegate collectionView:self.collectionView layout:self minimumColumnSpacingForSectionAtIndex:section];
}
return CHTFloorCGFloat((width - (columnCount - 1) * columnSpacing) / columnCount);
}
Swift:
public func itemWidth(inSection section: Int) -> CGFloat {
let columnCount = self.columnCount(forSection: section)
let spaceColumCount = CGFloat(columnCount - 1)
let width = collectionViewContentWidth(ofSection: section)
return floor((width - (spaceColumCount * minimumColumnSpacing)) / CGFloat(columnCount))
}
In Swift version, collectionView:layout:minimumColumnSpacingForSectionAtIndex not be called in real time. minimumColumnSpacing for section not work.