Giter Club home page Giter Club logo

pmbrowsingcollectionview's Introduction

PMBrowsingCollectionView

PMBrowsingCollectionView is a subclass of UICollectionView that implements a new interaction for easily browsing through a collection of cells by introducing the concept of expanded vs. collapsed sections.

Demo

Requirements & Notes

  • PMBrowsingCollectionView was built for iOS and requires a minimum iOS target of iOS 7.
  • Thorough commenting of header files is currently in progress. (6/12/14).
  • PMBrowsingCollectionView will not support resizing until dynamic cell resizing is added in iOS8

How To Get Started

  • Check out the documentation (coming soon).

Installation with CocoaPods

PMBrowsingCollectionView is available through CocoaPods. CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like PMBrowsingCollectionView in your projects. See the "Getting Started" guide for more information.

Podfile

To install, simply add the following line to your Podfile.

platform :ios, '7.0'
pod "PMBrowsingCollectionView"

Usage

To see PMBrowsingCollectionView in action, run the example project at /Example/PMBrowsingCollectionView-iOSExample.xcworkspace. After installing the PMBrowsingCollectionView pod, integrating into your project is as easy as creating a typical UICollectionView:

UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
layout.minimumInteritemSpacing = 2.0f;
layout.minimumLineSpacing = 2.0f;
	
PMBrowsingCollectionView *collectionView = [PMBrowsingCollectionView collectionViewWithFrame:self.view.bounds
                                                                            collectionViewLayout:layout];
collectionView.delegate = self;
collectionView.dataSource = self;
[collectionView registerClass:[UICollectionViewCell class]
            forCellWithReuseIdentifier:@"cellReuseIdentifier"];
[collectionView registerClass:[UICollectionReusableView class]
            forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
                   withReuseIdentifier:@"headerReuseIdentifier"];
[self.view addSubview:collectionView];
- (UICollectionViewCell *)collectionView:(PMBrowsingCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
	UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellReuseIdentifier" forIndexPath:indexPath];
	NSUInteger normalizedIndex = [collectionView normalizeItemIndex:indexPath.item forSection:indexPath.section];
	/*
	* Configure cell based on indexPath.section and normalizedIndex
	*/
	return cell;
}

PMBrowsingCollectionViewDelegate adds three optional methods to the UICollectionViewDelegateFlowLayout:

- (CGFloat) collectionView:(PMBrowsingCollectionView *)collectionView shadowRadiusForSection:(NSInteger)section
{
    return 20.0f;
}

- (UIColor *) collectionView:(PMBrowsingCollectionView *)collectionView shadowColorForSection:(NSInteger)section
{
    return [UIColor blackColor];
}

// Only called when section is in a collapsed state.
- (void) collectionView:(PMBrowsingCollectionView *)collectionView willCenterItemAtIndexPath:(NSIndexPath *)indexPath
{
	NSUInteger normalizedIndex = [collectionView normalizeIndex:indexPath.item];
	DLog(@"Will center cell at section index %d, item index %d", indexPath.section, normalizedIndex);
}

Discussion

  • To achieve infinite scrolling, PMCircularCollectionView employes a technique described in this blog post which multiplies the content size and consequently the number of index paths. Thus, it is possible for dataSource and delegate methods to pass an index path with item == 15, when less than 16 items were returned to the -collectionView:numberOfItemsInSection: delegate method. As seen in the examples above, call -normalizeItemIndex:forSection to change the item index to the correct value.

Communication

  • If you need help, use Stack Overflow. (Tag 'PMTabBarController')
  • If you'd like to ask a general question, use Stack Overflow.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Author

License

PMBrowsingCollectionView is available under the MIT license. See the LICENSE file for more info.

pmbrowsingcollectionview's People

Contributors

pm-dev avatar

Stargazers

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

Watchers

 avatar  avatar

pmbrowsingcollectionview's Issues

a bug in the didSelectItemAtIndexPath

like this:

  • (void) collectionView:(PMBrowsingCollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
    {
    NSInteger r = indexPath.row;
    NSInteger sec = indexPath.section;
    NSInteger item = indexPath.item;
    DLog(@"Selected item at %@", indexPath);
    }

Question is : the variable sec is always is 0, although I touch in the section 2,3 .....;

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.