viewForSupplementaryElementOfKind不执⾏的解决⽅法
为了降低代码耦合性,通常⾃定义UICollectionViewFlowLayout。今天在⾃定义UICollectionViewFlowLayout时,想设置UICollectionView 的footerView,但viewForSupplementaryElementOfKind不执⾏,改成系统的UICollectionViewFlowLayout就可以。世界末日几号
⾃定义UICollectionViewFlowLayout添加header 和footer的解决⽅法:
- (nullableNSArray<__kindofUICollectionViewLayoutAttributes*> *)layoutAttributesForElementsInRect:(CGRect)rect{ NSMutableArray*attributes = [[superlayoutAttributesForElementsInRect:rect]mutableCopy];
for(NSIntegeri =0; i <_numberOfCells; i++) {
尘肺病防治条例NSIndexPath*indexPath = [NSIndexPathindexPathForItem:iinSection:0]; UICollectionViewLayoutAttributes*attribute = [selflayoutAttributesForItemAtIndexPath:indexPath];
乌氏粘度计原理
[attributesaddObject:attribute];
}
bbc
for(UICollectionViewLayoutAttributes*attrsinattributes) {
if([attrsrepresentedElementKind] ==UICollectionElementKindSectionFooter) {
CGRectheaderRect = [attrsframe];
headerRect.size.height=100;
headerRect.size.width=SCREEN_SIZE.width;
[attrssetFrame:headerRect];
break;
王一伦}
returnattributes;
}