Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tweaks to reloading a very small view to prevent infinite loops

  • Loading branch information...
commit 42359d6851801e51c2fb754756cacefedbc7c9ee 1 parent 53753d5
@pieteromvlee pieteromvlee authored
View
8 BCCollectionView.m
@@ -488,6 +488,10 @@ - (void)reloadDataWithItems:(NSArray *)newContent groups:(NSArray *)newGroups em
if (!delegate)
return;
+ NSSize cellSize = [delegate cellSizeForCollectionView:self];
+ if (NSWidth([self frame]) < cellSize.width || NSHeight([self frame]) < cellSize.height)
+ return;
+
for (BCCollectionViewGroup *group in groups)
[group removeObserver:self forKeyPath:@"isCollapsed"];
for (BCCollectionViewGroup *group in newGroups)
@@ -553,6 +557,10 @@ - (void)viewDidResize
- (void)softReloadDataWithCompletionBlock:(dispatch_block_t)block
{
+ NSSize cellSize = [delegate cellSizeForCollectionView:self];
+ if (NSWidth([self visibleRect]) < cellSize.width || NSHeight([self visibleRect]) < cellSize.height)
+ return;
+
NSRange range = [self rangeOfVisibleItemsWithOverflow];
[layoutManager enumerateItems:^(BCCollectionViewLayoutItem *layoutItem) {
if (NSLocationInRange([layoutItem itemIndex], range)) {
View
7 BCCollectionViewLayoutManager.m
@@ -62,8 +62,11 @@ - (NSSize)cellSize
- (NSPoint)rowAndColumnPositionOfItemAtIndex:(NSUInteger)anIndex
{
- BCCollectionViewLayoutItem *itemLayout = [itemLayouts objectAtIndex:anIndex];
- return NSMakePoint(itemLayout.columnIndex, itemLayout.rowIndex);
+ if ([itemLayouts count] > anIndex) {
+ BCCollectionViewLayoutItem *itemLayout = [itemLayouts objectAtIndex:anIndex];
+ return NSMakePoint(itemLayout.columnIndex, itemLayout.rowIndex);
+ } else
+ return NSZeroPoint;
}
- (NSUInteger)indexOfItemAtRow:(NSUInteger)rowIndex column:(NSUInteger)colIndex
View
2  BCCollectionViewLayoutOperation.m
@@ -25,7 +25,7 @@ - (void)main
NSSize inset = NSZeroSize;
NSInteger maxColumns = [[collectionView layoutManager] maximumNumberOfItemsPerRow];
NSUInteger gap = (NSWidth([collectionView frame]) - maxColumns*cellSize.width)/(maxColumns-1);
- if (maxColumns < 4) {
+ if (maxColumns < 4 && maxColumns > 1) {
gap = (NSWidth([collectionView frame]) - maxColumns*cellSize.width)/(maxColumns+1);
startingX = gap;
x = gap;
Please sign in to comment.
Something went wrong with that request. Please try again.