Code Monkey home page Code Monkey logo

dtgridview's Introduction

DTGridView

A two-dimensional scrolling view component for the iPhone, heavily inspired by UITableView.

WARNING DTGridView 1.1 moves the location of all of the classes, so you may need to jiggle things about when updating.

Branch Structure

There are two branches to this repository, master and production, these are described below. (Thanks to Abizer for showing me this method.)

The master Branch

The master branch contains the class extension files as well as an Xcode project that demonstrates the code and is the branch to use to see how to use the code. It as also the branch that further development of the code should be performed on.

The production Branch

The production branch should be used if you want to add these extensions as a git submodule in other projects and will only contain the class files themselves without the Xcode project or example classes. This is preferable as it will keep your directories clean of any code which is unnecessary to your working project, of course you can switch branches in the submodule to access the given samples.

Changes made to the master branch will be merged across to production, so it will always remain current with respect to master.

To add the production branch rather than master, simply use the -b flag as shown below.

git submodule add -b production git://github.com/danielctull/DTGridView.git

To keep up to date with the latest changes `cd` into the directory that contains this submodule and pull the newest changes as usual

git pull origin

Artefacts

Sometimes, there may be artefacts left over when switching from master to production. These are files that are ignored by git and are easily cleaned up by running

git clean -dxf

Examples

Examples of some of these features can be found in the iPhone app delegate.

License

Copyright © 2010 Daniel Tull. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

dtgridview's People

Contributors

aufflick avatar danielctull avatar th-in-gs 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

dtgridview's Issues

Invalid array access when changing grid orientation

Invalid objectAtIndex access on the cell info array when calling a reloadData on the gridView and inverting the row and columns quantity.

I have a single row with multiple columns displayed in landscape and want to have a single column with multiple rows when displayed in portrait.

On the reloadData call, removeCellWithInfo is called with a cell info containing an invalid x, y value with the new rows and cells quantity.

reloadData removes all cells and doesn't add any back

After the gridView is initialized, if you call reloadData it removes all the cells but doesn't add them back. One specific suspicious spot is DTGridView ~line 384

if ([self.subviews count] > [self.gridCells count]) {

Problem is gridCells is a multidimensional array of the cells (row x column) where subviews is flat so that expression always evals to true. The meat of the issue is in checkViews, thats where cells should be added (it appears) but aren't, they're only added on initialiseViews.

Crash in removeCellWithInfo

Daniel

Please can you review & comment?

The two "greater than" tests for xPosition and yPosition should surely be "greater than or equal". If, for example info.yPosition = 3 and [gridCells count] = 3 then then next line [gridCells objectAtIndex:info.yPosition] evaluates to [gridCells objectAtIndex:3] and we get a range exception.

Regards

Chris & Murthy

  • (void)removeCellWithInfo:(DTGridViewCellInfo *)info {

    if (info.yPosition > [gridCells count]) return;
    
    NSMutableArray *row = [gridCells objectAtIndex:info.yPosition];
    
    if (info.xPosition > [row count]) return;
    

Fixed column on left hand side

Hi Daniel

I've love to use your grid view with the left-hand column pinned so that it's always in view. Can you think of any easy way of achieving this?

Regards

Chris

Cells in last row never get requested

I've got a grid 4 columns by R rows. I'm filling this grid with data such that each row might be only partially filled - 3 out of the 4 columns for example. Only 2 rows are on screen at any time (except during scrolling). It is a normal DTGridView that scrolls vertically.

The problem occurs when I have 4 rows. The first 3 are completely full (4/4 columns), and the last row is only partially full (1/4 columns). The DTGridView allows me to scroll to the 4th row, but the cell in the 4th row, 1st column never appears. I put logging statements in the gridView:viewForRow:column: method, and the cell is never even asked for.

Here's my pseudo code

  • (NSInteger)numberOfRowsInGridView:(DTGridView *)gridView {
    NSUInteger itemCount = ;
    return ceil((double)itemCount / (double)GRID_VIEW_NUM_VISIBLE_COLUMNS);
    }

  • (NSInteger)numberOfColumnsInGridView:(DTGridView *)gridView forRowWithIndex:(NSInteger)index {
    NSUInteger itemCount = ;
    NSUInteger rows = [self numberOfRowsInGridView:gridView];
    NSUInteger numItemsIfFilled = GRID_VIEW_NUM_VISIBLE_COLUMNS * rows;
    BOOL lastRow = (index == rows - 1);
    BOOL gridFull = itemCount == numItemsIfFilled;

    NSInteger columns = GRID_VIEW_NUM_VISIBLE_COLUMNS;

    if (lastRow && !gridFull) {
    columns = itemCount % GRID_VIEW_NUM_VISIBLE_COLUMNS;
    }

    return columns
    }

  • (CGFloat)gridView:(DTGridView *)gridView heightForRow:(NSInteger)rowIndex {
    return gridView.frame.size.height / GRID_VIEW_NUM_VISIBLE_ROWS;
    }

  • (CGFloat)gridView:(DTGridView *)gridView widthForCellAtRow:(NSInteger)rowIndex column:(NSInteger)columnIndex {
    return gridView.frame.size.width / GRID_VIEW_NUM_VISIBLE_COLUMNS;
    }

  • (DTGridViewCell *)gridView:(DTGridView *)gridView viewForRow:(NSInteger)rowIndex column:(NSInteger)columnIndex {
    return ;
    }

One thing to note is that when the number of rows fits on screen, the last row shows just fine. It is only when the last row does not fit on screen that it is not requested at all.

reloadData Issue

is there some limits to this grid that aren't documented?

I am trying to use this grid in a dynamic situation on a view controller, meaning the grid's data will change depending on actions taken on other parts of the screen. I also added landscape support as well and I am finding issues with the grid. When I need to refresh the data, I call [gridView reloadData], I assume this is what is needed to redraw and pickup the new values for number of rows/columns.

I am seeing weird things going on with Rows now not being rendered is some parts of the grid?

An easy way to see this test is to add the [gridView reloadData] to the selectionMadeAtRow event in the DTGridViewExampleDataSourceAndDelegate class.

This will break the grid to not show some rows, especially if you currently scrolled down far in a grid.

When dealing with screen rotation and/or updating the datasource, is there other steps I need to take to ensure the missing rows doesn't occur???

DTInfiniteGridViewExampleViewController not infinite scroll

Hi All,

When using the DTInfiniteGridViewExampleViewController in the demo project it seems that this does not demonstrate infinite horizontal scroll, as it stops horizontally scrolling after 10 cycles of the Red/Blue/Orange/Yellow views. Looking through the source code nothing jumps out as constraining the scroll to 10 cycles, and given that it should be infinite scroll I thought that it would just continue scrolling ad infinitum.

I am running the code in the iPhone Simulator using SDK 4.2. Thanks in advance for any assistance.

Reload table

Hi, I have trouble recharging the table. In doing so, the information is in the ranks just disappear. Try doing it this way,jpvasquez@4f536b5 , but got no positive results. I hope I can help.

spacingBetweenRowsInGridView and spacingBetweenColumnsInGridView are not used

spacingBetweenRowsInGridView and spacingBetweenColumnsInGridView are defined as optional methods in the DTGridViewDataSource protocol but don't appear to be referenced anywhere else in the code, so they have no effect. I'm still getting familiar with the code and will attempt to see how these might be implemented.

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.