⚠️The #116 is a new BUG !
madordie opened this issue · 8 comments
I find header attributed AND footer attributed THED merge return attributed
so . header and footer KEY == [NSIndexPath indexPathForItem:0 inSection:section]
The result is that the footer will MUST replace the header
Hi @madordie ,
Thanks for the information, but I don't have time to work on this.
Could you send a PR to fix this bug?
@madordie I'm sorry, I don't fully understand your comment.
If you're saying that the footer and header must not replace each other when they have the same indexPath
, then you could change the code so that it not only separates elements into different NSDictionary
s by their representedElementCategory
but also by their representedElementKind
.
My English is not very good, so I use this Google Translate
😂😂😂
DEMO-CHT # 166BUG
Reproduce the BUG described in #174.
The main steps
In the UICollectionViewWaterfallLayout.m -> - (void) prepareLayout
, set
NSIndexPath indexPathForItem: 0 inSection: section]`
In the UICollectionViewWaterfallLayout.m -> - (NSArray *) layoutAttributesForElementsInRect: (CGRect) rect
, using the NSDictionary
as the storage structure, use attr`` NSIndexPath
as the NSDictionary
key
So, when UICollectionViewWaterfallLayout.m -> - (NSArray *) layoutAttributesForElementsInRect: (CGRect) rect
need to return both header
and footer
'will appear. That is, value1
in dict
will be replaced by value2
.
NSMutableDictionary * dict = [NSMutableDictionary dictionary];
dict[@ "KEY"] = @ "value1";
dict[@ "KEY"] = @ "value2";
I wrote a demo
If it is my usage problem, we can discuss this issue together 😊
DEMO-CHT#166BUG
重现#174中所描述的BUG。
主要步骤
在 UICollectionViewWaterfallLayout.m -> - (void)prepareLayout
中,设置header
、footer
使用的NSIndexPath
定义均为[NSIndexPath indexPathForItem:0 inSection:section]
在 UICollectionViewWaterfallLayout.m -> - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
中,采用了NSDictionary
作为存储结构,使用attr
的NSIndexPath
作为NSDictionary
的key
所以,当UICollectionViewWaterfallLayout.m -> - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
需要同时返回header
和footer
将会出现header
被footer
替换的现象。即:dict
中的value1
将被value2
所替换。
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
dict[@"KEY"] = @"value1";
dict[@"KEY"] = @"value2";
我写了一个demo
如果是我的用法问题,我们可以一起在讨论一下这个问题😊
I got same error.
My collectionView have 1 section with header and footer, but only CHTCollectionElementKindSectionFooter
passing in
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
@madordie thanks, I just submitted a new PR and realized you made the exact same change 😝
😊
@chiahsien need update tag for cocoapods 😂
okay, new tag published!