Skip to content

Instantly share code, notes, and snippets.

@nicksnyder
Last active January 25, 2019 11:39

Revisions

  1. nicksnyder revised this gist Jul 31, 2013. 2 changed files with 4 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions NDCollectionViewFlowLayout.h
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    // Created by Nick Snyder on 11/13/12.
    // https://gist.github.com/nicksnyder/4075682
    // http://stackoverflow.com/questions/12927027/uicollectionview-flowlayout-not-wrapping-cells-correctly-ios
    // NDCollectionViewFlowLayout.h
    @interface NDCollectionViewFlowLayout : UICollectionViewFlowLayout

    2 changes: 2 additions & 0 deletions NDCollectionViewFlowLayout.m
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    // Created by Nick Snyder on 11/13/12.
    // https://gist.github.com/nicksnyder/4075682
    // http://stackoverflow.com/questions/12927027/uicollectionview-flowlayout-not-wrapping-cells-correctly-ios
    // NDCollectionViewFlowLayout.m
    #import "NDCollectionViewFlowLayout.h"

  2. nicksnyder revised this gist Apr 12, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion NDCollectionViewFlowLayout.m
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,8 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
    NSArray *attributes = [super layoutAttributesForElementsInRect:rect];
    NSMutableArray *newAttributes = [NSMutableArray arrayWithCapacity:attributes.count];
    for (UICollectionViewLayoutAttributes *attribute in attributes) {
    if (attribute.frame.origin.x + attribute.frame.size.width <= self.collectionViewContentSize.width) {
    if ((attribute.frame.origin.x + attribute.frame.size.width <= self.collectionViewContentSize.width) &&
    (attribute.frame.origin.y + attribute.frame.size.height <= self.collectionViewContentSize.height)) {
    [newAttributes addObject:attribute];
    }
    }
  3. nicksnyder revised this gist Nov 14, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion NDCollectionViewFlowLayout.m
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    // NDCollectionViewFlowLayout.m
    #import "NDCollectionViewFlowLayout.h"

    @implementation MTCollectionViewFlowLayout
    @implementation NDCollectionViewFlowLayout

    - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
    NSArray *attributes = [super layoutAttributesForElementsInRect:rect];
  4. nicksnyder created this gist Nov 14, 2012.
    5 changes: 5 additions & 0 deletions NDCollectionViewFlowLayout.h
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    // Created by Nick Snyder on 11/13/12.
    // NDCollectionViewFlowLayout.h
    @interface NDCollectionViewFlowLayout : UICollectionViewFlowLayout

    @end
    18 changes: 18 additions & 0 deletions NDCollectionViewFlowLayout.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    // Created by Nick Snyder on 11/13/12.
    // NDCollectionViewFlowLayout.m
    #import "NDCollectionViewFlowLayout.h"

    @implementation MTCollectionViewFlowLayout

    - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
    NSArray *attributes = [super layoutAttributesForElementsInRect:rect];
    NSMutableArray *newAttributes = [NSMutableArray arrayWithCapacity:attributes.count];
    for (UICollectionViewLayoutAttributes *attribute in attributes) {
    if (attribute.frame.origin.x + attribute.frame.size.width <= self.collectionViewContentSize.width) {
    [newAttributes addObject:attribute];
    }
    }
    return newAttributes;
    }

    @end