Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️The #116 is a new BUG ! #174

Closed
madordie opened this issue Jun 21, 2017 · 8 comments
Closed

⚠️The #116 is a new BUG ! #174

madordie opened this issue Jun 21, 2017 · 8 comments

Comments

@madordie
Copy link

#166 @rafaelcr @chiahsien

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

@chiahsien
Copy link
Owner

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?

@rafaelcr
Copy link
Contributor

@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 NSDictionarys by their representedElementCategory but also by their representedElementKind.

@madordie
Copy link
Author

madordie commented Jun 22, 2017

@rafaelcr

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 中,设置headerfooter使用的NSIndexPath定义均为[NSIndexPath indexPathForItem:0 inSection:section]

UICollectionViewWaterfallLayout.m -> - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect中,采用了NSDictionary作为存储结构,使用attrNSIndexPath作为NSDictionary的key

所以,当UICollectionViewWaterfallLayout.m -> - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect需要同时返回headerfooter将会出现headerfooter替换的现象。即:dict中的value1将被value2所替换。

NSMutableDictionary *dict = [NSMutableDictionary dictionary];
dict[@"KEY"] = @"value1";
dict[@"KEY"] = @"value2";

我写了一个demo

如果是我的用法问题,我们可以一起在讨论一下这个问题😊

@ericwang24
Copy link

ericwang24 commented Jun 22, 2017

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

@rafaelcr
Copy link
Contributor

@madordie thanks, I just submitted a new PR and realized you made the exact same change 😝

@madordie
Copy link
Author

😊

@madordie
Copy link
Author

madordie commented Sep 5, 2017

#179

@chiahsien need update tag for cocoapods 😂

@chiahsien
Copy link
Owner

okay, new tag published!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants