Giter Club home page Giter Club logo

uicollectionviewleftalignedlayout's Introduction

UICollectionView Left Aligned Layout

A UICollectionViewLayout implementation that aligns the cells to the left.

Check out the twin project UICollectionViewRightAlignedLayout

Installation with CocoaPods

platform :ios, '6.0'

pod 'UICollectionViewLeftAlignedLayout'

Usage

Simply set UICollectionViewLeftAlignedLayout as the layout object for your collection view either via code:

CGRect frame = ...
UICollectionViewLeftAlignedLayout *layout = [[UICollectionViewLeftAlignedLayout alloc] init];
UICollectionView *leftAlignedCollectionView = [[UICollectionView alloc] initWithFrame:frame collectionViewLayout:layout];

or from Interface Builder:

img needed here

UICollectionViewLeftAlignedLayout is a subclass of UICollectionViewFlowLayout, so your collection view delegate can use all the delegate methods of UICollectionViewDelegateFlowLayout.

For those of you who like consistency there is an UICollectionViewDelegateLeftAlignedLayout protocol that your delegate object can conform to. Is nothing more than an empty extension of UICollectionViewDelegateFlowLayout.

License

UICollectionViewLeftAlignedLayout is released under the MIT license.


Hacked together with passion by @mokagio

uicollectionviewleftalignedlayout's People

Contributors

auswahlaxiom avatar bb9z avatar cyupa avatar mokagio avatar mussacharles avatar nuudles avatar sandychapman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uicollectionviewleftalignedlayout's Issues

Recursive loop when implementing cell's `preferredLayoutAttributesFittingAttributes:`

Possibly related to #11

If using estimated item sizes:

layout.estimatedItemSize = CGSizeMake(50, 50);

in combination with UICollectionViewCell override of:

- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    CGFloat randomWidth = (arc4random() % 120) + 60;
    layoutAttributes.size = CGSizeMake(randomWidth, 60);
    return layoutAttributes;
}

Application will fall into recursive loop.

section headers not correctly positioned

When I applied the layout to a collectionView with section headers, the headers except the first one were not correctly positioned. It seemed that the origin of the headers were the same as that of the first row of cells in the same section. Any suggestion? Is it a bug, or have I miss anything? Thx

cellForItemAtIndexPath not getting called

This is odd. I've been using this in a project for quite a while and it was working fine. I recently did a new build and now the collection view I'm using this for doesn't show any items. In the debugger I can see that numberOfItemsInSection is returning the correct (> 0) number -- but cellForItemAtIndexPath is never getting called.

I tried switching to the cocoapod and updating to the latest -- same thing.

Anyone else seeing this? Any thoughts?

Additional info -- I've been using estimatedItemSize and a cell w/ autolayout.

If I comment out the estimatedItemSize assignment, the cells appear (but are all sized the same).

Thanks
John

Who's using the pod?

I'd love to know how you are using UICollectionViewLeftAlignedLayout, please leave a comment here with a link to the app, and/or a screenshot.

Thanks 😄

Use in UIInterfaceOrientation Portrait some problem

po 0x79e6eb30
ProductSuitColletCell: 0x79e6eb30; baseClass = UICollectionViewCell; frame = (0 0; 171 185);

(lldb) po 0x7c97f6e0
ProductSuitColletCell: 0x7c97f6e0; baseClass = UICollectionViewCell; frame = (0 0; 171 185);

you can see the two cell's frame is same

Scrolling Issue...

Hello...I have used this by downloading the files and set Class to UICollectionViewLeftAlignedLayout but at first time it gets stuck while scrolling and then scrolls properly...So please help me with this issue...

iOS 11.4 return UIEdgeInsetsMake(10, 10 10, 10); Right constraint invalid

iOS 11.4 return UIEdgeInsetsMake(10, 10 10, 10); Right constraint invalid
iOS 14.4 normal display

  • (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(10, 10 10, 10);
    }

EXC_BAD_ACCESS

I am getting a crash when using UICollectionViewLeftAlignedLayout on line 47. This only occurs if I set estimatedItemSize to use dynamic sizing.

NSArray *originalAttributes = [super layoutAttributesForElementsInRect:rect];

Podspec is still pointing to 1.0.2

Hey,

First of all, thank you for awesome library! I noticed that the latest tag is 1.0.3 which added Swift 4 support but the podspec is still pointing to 1.0.2.

有个小bug

当我有一个section的cell的宽度都为屏幕宽度的时候,这个section的cell就会错乱

cached frame mismatch

hey there, first of all nice pod :)

It's working for me, but I get this warning. Any clues?

UICollectionViewFlowLayout has cached frame mismatch for index path <NSIndexPath: 0xc000000000200016> {length = 2, path = 0 - 1} - cached value: {{179, 0}, {136.33333333333334, 30}}; expected value: {{217.66666666666666, 0}, {136.33333333333334, 30}}

This is likely occurring because the flow layout subclass UICollectionViewLeftAlignedLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.