Giter Site home page Giter Site logo

easytableview's Introduction

EasyTableView Notes - Updated January 10, 2013

IMPORTANT NOTE: The API for EasyTableView has changed of March 1, 2012. So if you have been a consumer of EasyTableView prior to this date, you may find that this update breaks your existing projects. This new release has support for multiple sections, and section headers and footers. To fix any problems created by this update, simply replace any "index" parameter with an "indexPath" parameter. If you don't have an indexPath parameter, you can easily create an indexPatch for an index with:

	NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];

SUMMARY

This project demonstrates the use of the EasyTableView class. The demo is intended to be run on an iPad only, but there is no reason why EasyTableView could not be used on an iPhone.

To use EasyTableView in your own project, all you need to include are the following files:

EasyTableView.h
EasyTableView.m

DESCRIPTION

EasyTableView was created to address two concerns. The first is the ability to have a table view, horizontal or vertical, that only partially fills the screen. Normally one would use UITableViewController but as per Apple documentation, that requires table views that fill the whole screen. EasyTableView addresses this problem by acting as the controller for the embedded table view, and exposes a subset of table view functionality with it's own delegate methods.
 
The second concern addressed by EasyTableView is horizontal table views. Table views were initially designed to be vertical only. EasyTableView solves this problem by rotating the table view, and then reverse rotating table view cells. One could also provide horizontally scrolling table views by subclassing UIScrollView, but I wanted to create one simple, common interface for creating both vertical EasyTableViews and horizontal EasyTableViews.
 
So now you can create simple partial screen table views, either vertically or horizontally, all with the same interface.

CHANGES

JANUARY 10, 2013 - Version 1.1
Updated for iOS 6. Also added new setScrollFraction method added which will scroll the table view to a fraction of the total scroll length.

MARCH 5, 2012
Updated to support ARC. EasyTableView now requires ARC.

MARCH 1, 2012
Whereas before EasyTableView was implemented to work with only one table view section, it has now been generalized to work with multiple table view sections. It also now supports section headers and footers. If you would like too see the demo run using just a single table view section, comment out the following line in EasyTableViewController.m:

	#define SHOW_MULTIPLE_SECTIONS	1

JANUARY 31, 2012
The sample project has been updated with a comprehensive example that demonstrates the use of EasyTableView with public images loaded from the Flickr website. Tap the info button to see that example in action. If you get an error, please tap Done and try again. The use of EasyTableView with remote images is implemented in FlipsideViewController.

KNOWN LIMITATIONS
 
1. EasyTableView relies on three reserved view tags, 800 - 802.

2. A horizontal EasyTableView will correctly auto-resize it's overall length. However a horizontal EasyTableView will NOT necessarily correctly auto-resize it's height.

3. Loading the Flickr catalog will sometimes fail due to JSON parsing errors. 

USAGE

To understand how to use EasyTableView, study the code in EasyTableViewController.m or FlipsideViewController.m. To create a new EasyTableView object, look at the methods (void)setupHorizontalView and (void)setupVerticalView. As seen in the source code, you initialize a vertical scrolling table view with:

- (id)initWithFrame:(CGRect)frame numberOfRows:(NSUInteger)numCells ofHeight:(CGFloat)cellHeight;

To initialize a horizontal scrolling table view use:

- (id)initWithFrame:(CGRect)frame numberOfColumns:(NSUInteger)numCells ofWidth:(CGFloat)cellWidth;

The numberOfRows or numberOfColumns parameters in the above two methods are only used if you are implementing an EasyTableView with one section. Otherwise, those parameters are ignored and can be set to anything. If you plan to setup an EasyTableView with multiple sections, you must implement the following two delegate methods:

- (NSUInteger)numberOfSectionsInEasyTableView:(EasyTableView*)easyTableView;
- (NSUInteger)numberOfCellsForEasyTableView:(EasyTableView *)view inSection:(NSInteger)section;

There are two delegate methods for the EasyTableViewDelegate protocol that must always be implemented. They are:

- (UIView *)easyTableView:(EasyTableView *)easyTableView viewForRect:(CGRect)rect;
- (void)easyTableView:(EasyTableView *)easyTableView setDataForView:(UIView *)view forIndexPath:(NSIndexPath *)indexPath;

In the first delegate method you are required to return a UIView object (or UIView subclass) which fits within the bounds of the "rect" parameter. The simplest thing to do is to create a UIView object with the frame set to "rect". In the demo you will see that a UIView is created which is inset, simply for aesthetics. This delegate method is intended only to create the custom views for each of your cells, NOT the data. It is called N times, where N is the number of cells specified when an EasyTableView object is first initialized (if you have a single section).

The second delegate method is where you set the data for each of your cells, given a specified "indexPath". The "view" parameter is the same UIView object (or subclass) that was returned from your implementation of the first delegate method.

That's all there is to it. It is very easy to use. There are additional methods defined in EasyTableView.h that you might also find useful for your own application:

- (void)selectCellAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated;
- (UIView *)viewAtIndexPath:(NSIndexPath *)indexPath;
- (NSIndexPath*)indexPathForView:(UIView *)cell;

- (void)setContentOffset:(CGPoint)offset animated:(BOOL)animated;
- (CGPoint)offsetForView:(UIView *)cell;

And yes, that is a picture of my tent!


EasyTableView is released under the New BSD License.

Copyright (c) 2010-2012, Yodel Code LLC
All rights reserved.

easytableview's People

Contributors

alekseyn avatar brandoncopley avatar vtim avatar

Watchers

 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.