UICollectionView displays cells incorrectly after frame change
ios, uicollectionview
Solution
I had a similar problem, where my `UICollectionView`'s `frame` changed and unless I call `reloadData` it got stuck in the same spot without moving with the `CollectionView`.
I've fixed it by adding this to my CollectionViewFlowLayout:
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds
{
return YES;
}
Worked nicely.
Problem
I noticed that if I change the frame of a UICollectionView (e.g. when the toggling the in-call status bar), the collection view doesn't update its cells properly for its new frame. It's probably easiest to see in a short video: http://cl.ly/2t2Y2A3A2w1D/CollectionViewTest.mov The source files for that simple test are here: http://cl.ly/0S0A360B3I3Q/CollectionViewTest.zip It doesn't seem to matter whether I use UICollectionViewController or UIViewController. Has anyone seen this? Am I missing something? The only workaround I've found is to call reloadData on the collection view in the view controller's viewWillLayoutSubviews or viewDidLayoutSubviews which works but is far from ideal when the collection view's frame is being affected by a user drag since reloadData is called many times and results in very sluggish UI updates while the user is dragging.