Coder Social home page Coder Social logo

williamren / ppimagescrollingtableviewcell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from popochess/ppimagescrollingtableviewcell

0.0 2.0 0.0 7.74 MB

PPImageScrollingTableViewCell is a UITableViewCell subclass that can make images scrollable horizontally in TableView.

ppimagescrollingtableviewcell's Introduction

PPImageScrollingTableViewCell

PPImageScrollingTableViewCell is a UITableViewCell subclass that can make images scrollable horizontally in TableView.

PPImageScrollingTableViewCell allows to customize the cell to match your needs and uses delegate callbacks to handle actions in your UITableViewController

DemoAnimation

##Installing Add all files under PPImageScrollingTableViewCell folder to your project. Import the class header and register the cell class in your UITableView.

##Usage Set sample data first. use @"category" and @"images" for key of Dictionary

@property (strong, nonatomic) NSArray *images;
self.images = @[
                  @{ @"category": @"Category A",
                     @"images":
                         @[
                             @{ @"name":@"sample_1", @"title":@"A-0"},
                             @{ @"name":@"sample_2", @"title":@"A-1"},
                             @{ @"name":@"sample_3", @"title":@"A-2"},
                             @{ @"name":@"sample_4", @"title":@"A-3"},
                             @{ @"name":@"sample_5", @"title":@"A-4"},
                             @{ @"name":@"sample_6", @"title":@"A-5"}
                          ]
                      },
                  @{ @"category": @"Category B",
                     @"images":
                         @[
                             @{ @"name":@"sample_3", @"title":@"B-0"},
                             @{ @"name":@"sample_1", @"title":@"B-1"},
                             @{ @"name":@"sample_2", @"title":@"B-2"},
                             @{ @"name":@"sample_5", @"title":@"B-3"},
                             @{ @"name":@"sample_6", @"title":@"B-4"},
                             @{ @"name":@"sample_4", @"title":@"B-5"}
                          ]
                    }
                ];

Add PPImageScrollingTableViewCellDelegate in your header file if you want to receive delegate callbacks on cell interactions

#import "PPImageScrollingTableViewCell.h"

-(void)viewDidLoad 
{
    [super viewDidLoad];
    [self.tableView registerClass:[PPImageScrollingTableViewCell class] forCellReuseIdentifier:CellIdentifier];
}

Subclass PPImageScrollingTableViewCell in tableview delegate

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *CellIdentifier = @"Cell";
    NSDictionary *cellData = [self.images objectAtIndex:[indexPath section]];
    PPScrollingTableViewCell *customCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    [customCell setDelegate:self];
    [customCell setImageData:cellData];
    [customCell setCategoryLabelText:[cellData objectForKey:@"category"] withColor:[UIColor whiteColor]];
    [customCell setTag:[indexPath section]];
    [customCell setImageTitleTextColor:[UIColor whiteColor] withBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.7]];
    [customCell setImageTitleLabelWitdh:90 withHeight:45];
    [customCell setCollectionViewBackgroundColor:[UIColor darkGrayColor]];
    
    return customCell;
}

##PPImageScrollingTableViewCell Delegate Methods

// Notifies the delegate when user click image
- (void)scrollingTableViewCell:(PPScrollingTableViewCell *)scrollingTableViewCell didSelectImageAtIndexPath:(NSIndexPath*)indexPathOfImage atCategoryRowIndex:(NSInteger)categoryRowIndex;

##License

PPImageScrollingTableViewCell is released under the MIT license.

ppimagescrollingtableviewcell's People

Contributors

popochess avatar

Watchers

william avatar James Cloos avatar

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.