Giter Site home page Giter Site logo

edgency / jmotableviewdescription Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leverdeterre/jmotableviewdescription

0.0 2.0 0.0 540 KB

JMOTableViewDescription is an Objective-C library for easily creating and manage complex structured tableView.

License: MIT License

jmotableviewdescription's Introduction

Purpose

JMOTableViewDescription is an Objective-C library for easily creating and manage complex structured tableView.

Image

Why this project?

  • TableView protocols are simple but not adapted to manipulate heterogenous objets or cells in your TableView.
  • Some situations can lead to very complicated algorithms to construct the right TableViewCell to present a particular object.
  • SectionHeaderView not reusable?

This project present:

  • A new way to describe your tableView "layout" with a very simple method (a model),
  • Datasource / Delegate considerably simplified by using this model,
  • It's a very simple way to produce a "grouped tableView" style without having to use grouped stype!
  • The code produced using this implementation his highly customizable, reusable and flexible. (No more bugs?)
  • TableView delegate and datasource focus on manipulated objet, no indexPath!,
  • HeaderView reuse ? Replace your header by a cell, your first row :)

Supported iOS & SDK Versions

  • Supported build target - iOS 7.1 (Xcode 5.1)
  • Earliest supported deployment target - iOS 5.0
  • Earliest compatible deployment target - iOS 5.0

NOTE: 'Supported' means that the library has been tested with this version. 'Compatible' means that the library should work on this iOS version (i.e. it doesn't rely on any unavailable SDK features) but is no longer being tested for compatibility and may require tweaking or bug fixes to run correctly.

TableViewDescription methods making the life easier

- (void)registerCellClassesIntoTableView:(UITableView *)tableView;

Auto register your classes into your tableView. You can implement a similar methods to register your nibs in your tableView (no more dequeReusableCell problems).

- (void)reloadDataFromDescription:(JMOTableViewDescription *)fromDescription 
                    toDescription:(JMOTableViewDescription *)toDescription 
                         animated:(BOOL)animated;

A full dynamic way to reload of your tableView to animated cell modification. It's a better UI effect than a reloadData.

TableViewDatasource / Delegate simplicty ?

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.tableViewDescription.sectionsDescription.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    JMOTableViewSectionDescription *tableSection = self.tableViewDescription.sectionsDescription[section];
    return tableSection.rowDescriptions.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    JMOTableViewRowDescription *rowDesc = [self.tableViewDescription rowDescriptionForIndexPath:indexPath];
    return rowDesc.cellHeight;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    JMOTableViewSectionDescription *sectionDesc = [self.tableViewDescription sectionDescriptionForSection:section];
    return sectionDesc.sectionHeight;
}

TableViewDescription exemple

Subclass the default JMOTableViewDescription and declare your method to generate your custom TableViewDescription.

@interface JMODemoTableViewDescription : JMOTableViewDescription
+ (JMODemoTableViewDescription *)descriptionNumber:(NSInteger)number;
@end
@implementation JMODemoTableViewDescription
+ (JMODemoTableViewDescription *)descriptionNumber:(NSInteger)number
{
  //Declare your TableView description
  JMODemoTableViewDescription *desc = [JMODemoTableViewDescription new];

  //Declare your first section description
  JMOTableViewSectionDescription *oneSection = [JMOTableViewSectionDescription new];
  oneSection.sectionHeight = 0.0f;

  //Declare your rows descriptions
  JMOTableViewRowDescription *oneRow = [JMOTableViewRowDescription new];
  oneRow.cellClass = [UITableViewCell class];
  oneRow.cellHeight = 30.0f;
  oneRow.cellReuseIdentifier = @"UITableViewCellIdentifier";
  oneRow.data = @"My first cell";
  //add your row description to your section
  [oneSection addRowDescription:oneRow];

  oneRow = [JMOTableViewRowDescription new];
  oneRow.cellClass = [JMOTableViewCellBlue class];
  oneRow.cellHeight = 44.0f;
  oneRow.cellReuseIdentifier = @"JMOTableViewCellBlue";
  oneRow.data = [NSString stringWithFormat:@"%@ (%d)",oneRow.cellReuseIdentifier,(int)oneRow.cellHeight];
  //add your row description to your section
  [oneSection addRowDescription:oneRow];

  //add one optional row??
  if(number == 2) {
      oneRow = [JMOTableViewRowDescription new];
      oneRow.cellClass = [JMOTableViewCellRed class];
      oneRow.cellHeight = 44.0f;
      oneRow.cellReuseIdentifier = @"JMOTableViewCellRed";
      oneRow.data = [NSString stringWithFormat:@"%@ (%d)",oneRow.cellReuseIdentifier,(int)oneRow.cellHeight];
      //add your optional row description to your section
      [oneSection addRowDescription:oneRow];
  }

  oneRow = [JMOTableViewRowDescription new];
  oneRow.cellClass = [JMOTableViewCellRed class];
  oneRow.cellHeight = 44.0f;
  oneRow.cellReuseIdentifier = @"JMOTableViewCellRed";
  oneRow.data = [NSString stringWithFormat:@"%@ (%d)",oneRow.cellReuseIdentifier,(int)oneRow.cellHeight];
  //add your row description to your section
  [oneSection addRowDescription:oneRow];

  //add your section description to your tableView decription
  [desc.sectionsDescription addObject:secondSection];
}
@end

Versions

  • Initial release

jmotableviewdescription's People

Contributors

leverdeterre avatar

Watchers

James Cloos avatar edgency 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.