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

Inserted cell is overlayed on top of existing cells #27

Closed
evil159 opened this issue Mar 6, 2019 · 6 comments
Closed

Inserted cell is overlayed on top of existing cells #27

evil159 opened this issue Mar 6, 2019 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@evil159
Copy link

evil159 commented Mar 6, 2019

Describe the bug
With quite simple setup(two sections - first one is empty, second has one cell with static height), after inserting an item into the collection view the inserted cell is overlayed over the existing one.

To Reproduce
Steps to reproduce the behavior:

  1. Set collection view's contentInsets to .zero
  2. Setup data source with one empty section(first) and another section with 1 item
  3. Insert an item into the first section

Expected behavior
Existing cell is pushed down by inserted cell.

Actual behaviour
Inserted cell is overlaid on top of existing cell.

Screenshots
magazinelayout_i MagazineLayout.zip nsert_issue

Smartphone (please complete the following information):

  • iPhone 8 Simulator(iOS 12), iPad(6th generation) Simulator(iOS 12), iPad (6th generation)(iOS 11)

Additional context
If collection view's contentInsets have any kind of horizontal margins(even UIEdgeInsets(top: 0, left: 1, bottom: 0, right: 1)) - it does seems to help. Not sure why this is happening, I modified example app to show the issue. MagazineLayout.zip

@bryankeller bryankeller self-assigned this Mar 6, 2019
@bryankeller bryankeller added the bug Something isn't working label Mar 6, 2019
@bryankeller
Copy link
Contributor

@evil159 you've discovered https://openradar.appspot.com/radar?id=5025850143539200 - a UICollectionView bug that I discovered and reported to Apple a few months back. It affects flow layout as well.

Perhaps MagazineLayout should warn people if batch updates are attempted with 0 horizontal insets. I feel like many people might run into this issue.

@evil159
Copy link
Author

evil159 commented Mar 6, 2019

@bryankeller I think it is a bit different issue, it also reproduces with static cell sizes. In the example provided there are two cells 30 an 60 pixels hight, the heights are defined statically. I tried to investigate it - it does not seem to be an issue with section height calculation - it's all ok there, looks like it is something else.

@bryankeller
Copy link
Contributor

Ah yes, this does seem different - the bug that I linked to should only cause incorrect animations, not leave the layout in an incorrect state. I'm digging into this today.

@bryankeller
Copy link
Contributor

@evil159 see that PR for more information, and a workaround

@bryankeller
Copy link
Contributor

This issue, and the related one from the open radar, is fixed in v1.2.2. Thank you for flagging this issue and providing a great repro project @evil159!

@evil159
Copy link
Author

evil159 commented Mar 14, 2019

Nice, thank you so much for looking into it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants