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.
Status Message | Paging | Paging in Progress |
---|---|---|
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.
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:
@interface ExamplePagedTableViewController : FGPagedTableViewController <FGPagedTableViewControllerDelegate, FGPagedTableViewControllerDataSource>
- (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
}
// 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;
Read the full documentation
- iOS 5.1.1
- Apple LLVM 4.0+ (ARC, auto-synthesize, literals and subscripting)
Feel free to fork and submit pull requests. This project is very early in development and I'm open to any improvements.
FGPagedTableViewController is available under the MIT license. See the LICENSE file for more info.