diff --git a/CHANGELOG.md b/CHANGELOG.md index 24369223..e3892781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ This release closes the [2.1.0 milestone](https://github.com/Instagram/IGListKit - Fix out-of-bounds bug when child section controllers in a stack remove cells. [Ryan Nystrom](https://github.com/rnystrom) [(#358)](https://github.com/Instagram/IGListKit/pull/358) +- Fix a grid layout bug when item has full-width and iter-item spacing is not zero. [Bofei Zhu](https://github.com/zhubofei) [(#361)](https://github.com/Instagram/IGListKit/pull/361) + 2.0.0 ----- diff --git a/Source/IGListGridCollectionViewLayout.m b/Source/IGListGridCollectionViewLayout.m index ab1c3d20..a5ca0010 100644 --- a/Source/IGListGridCollectionViewLayout.m +++ b/Source/IGListGridCollectionViewLayout.m @@ -219,6 +219,10 @@ NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:i]; id delegate = (id) collectionView.delegate; const CGSize itemSize = [delegate collectionView:collectionView layout:self sizeForItemAtIndexPath:indexPath]; + + IGAssertMainThread(); + IGAssert(itemSize.width <= self.contentWidth, @"The width of a single item must not exceed the width of the collection view."); + _IGListGridLayoutLine *lastLine = [self.lineCache lastObject]; if (![lastLine addItemToTailWithSize:itemSize]) { // Not enough space for the last line @@ -260,7 +264,7 @@ _minimumInteritemSpacing = spacing; _itemSizes = [NSMutableArray array]; _headIndex = headIndex; - _tailSpace = frame.size.width - self.minimumInteritemSpacing; + _tailSpace = frame.size.width; } return self; }