Giter Site home page Giter Site logo

msgridview's Introduction

MSGridView

A grid of grids iOS component with cell recycling equivalent to a UITableView

Installation

Copy MSGridView.h, MSGridView.m, MSGridViewCell.h and MSGridViewCell.m into your project.

Usage

In your view controller (e.g. in viewDidLoad) initialise and add the view

MSGridView *gridView = [[MSGridView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:gridView];

Then you need to setup delegate and datasource

gridView.gridViewDelegate = self;
gridView.gridViewDataSource = self;

From there you can set a few parameters:

Paging - by default this is on. Disable with:

self.pagingEnabled = NO;

Inner spacing (gaps between grids):

[gridView setInnerSpacing:CGSizeMake(100, 100)];

Delegate / DataSource methods

See MSGridView.h but...

Required Datasource methods:

// returns the cell for a specific grid row/column, row/column set
-(MSGridViewCell *)cellForIndexPath:(NSIndexPath*)indexPath inGridWithIndexPath:(NSIndexPath *)gridIndexPath;
 
// Returns the number of supergrid rows
-(NSUInteger)numberOfGridRows;
 
// Returns the number of supergrid rows
-(NSUInteger)numberOfGridColumns;

All basically the same as a UITableView

Option methods:

// for each given super grid, how many rows do we have? Default 1
-(NSUInteger)numberOfRowsForGridAtIndexPath:(NSIndexPath *)indexPath;
 
// for each given super grid, how many columns do we have? Default 1
-(NSUInteger)numberOfColumnsForGridAtIndexPath:(NSIndexPath *)indexPath;
 
// the size of an individual grid cell row / column. Default is the view width / number rows or columns
-(float)heightForCellRowAtIndex:(NSUInteger)row forGridAtIndexPath:(NSIndexPath *)gridIndexPath;
-(float)widthForCellColumnAtIndex:(NSUInteger)column forGridAtIndexPath:(NSIndexPath *)gridIndexPath;
 
// detect a touch event on a cell
-(void)didSelectCellWithIndexPath:(NSIndexPath*) indexPath;

Custom MSGridViewCells

Just subclass MSGridViewCell and modify in the same way as a custom UIViewCell. At current this is just an empty UIView so there are no default labels etc. Make sure you init with - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)identifier.

Demo

Run the XCodeProject

msgridview's People

Contributors

martingsaunders avatar

Watchers

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