Instagram / IGListKit

A data-driven UICollectionView framework for building fast and flexible lists.
https://instagram.github.io/IGListKit/
MIT License
12.84k stars 1.54k forks source link

bindViewModel has wrong cellSize #1248

Open maxifuchs opened 5 years ago

maxifuchs commented 5 years ago

General information

Hello, I think I found a bug: If you call contentView.frame.size inside your bindViewModel method, it returns the size of the xib (in storyboard), not the size of the cell, which was specified in the sectionController(_ sectionController: ListBindingSectionController<ListDiffable>, sizeForViewModel viewModel: Any, at index: Int). This bug also occurs in the IGListKit-Binding-Guide example project.

The cell still has the right size (from sizeForViewModel), but I’m creating a MKSnapshotter inside bindViewModel, which unfortunately uses the wrong size of the contentView.

In my project, the bug only occurs when the cell is loaded for the first time. After that, contentView.frame.size returns the correct size.

rnystrom commented 5 years ago

This is probably an issue with how XIBs work. We don’t use them at all in Instagram so I’m not surprised this hasn’t come up.

Can you repro the issue in an example app or better-yet unit test?

I won’t be able to work on a fix for this, but I’d gladly accept a PR!

Sent with GitHawk

mstafakv commented 4 years ago

https://github.com/thelinuxchoice/choicebot