Skip to content

UITableViewController subclass that adds status and manual paging functionality.

License

Notifications You must be signed in to change notification settings

FernGlow/FGPagedTableViewController

Repository files navigation

FGPagedTableViewController is a UITableViewController subclass that adds status message and paging functionality. It was modeled after Apple's server-side search functionality in the iOS Mail app.

FGPagedTableViewController In Action

Status Message Paging Paging in Progress

Getting Started

Limitations

For simplicity, the following design is used:

  • Section 1 of the table view contains the status cells (automatically provided)
  • Section 2 of the table view contains the result cells (the cells your FGPagedTableViewControllerDataSource provides)
  • Section 3 of the table view contains the paging cells (automatically provided)

Because of the current design, multi-section table view's are not supported. I encourage pull requests for an improved design that supports this.

Important

You do not need to, and shouldn't, implement any of the following UITableView data source or delegate methods as they are all handled by the FGPagedTableViewController class:

If you call any of the following data source or delegate methods, you must remember to call super's implementation:

1. Subclass the controller and adopt the delegate and data source protocols

@interface ExamplePagedTableViewController : FGPagedTableViewController <FGPagedTableViewControllerDelegate, FGPagedTableViewControllerDataSource>

2. Implement the required delegate and data source methods

- (UITableViewCell *)pagedTableView:(UITableView *)tableView resultCellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier" forIndexPath:indexPath];
	// configure cell properties
	return cell;
}

- (NSInteger)numberOfRowsInPagedData
{
	// return number of items to be paged through
}

- (void)pagedTableView:(UITableView *)tableView didSelectPagingCellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	// request a new page of data
}

3. Update the pageInfo object after you receive new data for the table view

// Create a new FGPageInfo instance
PageInfo *pageInfo = [[PageInfo alloc] init];

// configure pageInfo according to your data source
pageInfo.totalResults = 26;
pageInfo.totalPages = 6;
pageInfo.page = 1;

// update pageInfo with the latest paging information
// this triggers updates to the tableView, so do this last.
self.pageInfo = pageInfo;

Documentation

Read the full documentation

Requirements

  • iOS 5.1.1
  • Apple LLVM 4.0+ (ARC, auto-synthesize, literals and subscripting)

Contributions

Feel free to fork and submit pull requests. This project is very early in development and I'm open to any improvements.

License

FGPagedTableViewController is available under the MIT license. See the LICENSE file for more info.

About

UITableViewController subclass that adds status and manual paging functionality.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages