In the development process of a project, the pull-down refresh and update data are often used for better experience. Of course, there are also some situations where more data is loaded by pulling up; currently, the popular EGOTableViewPullRefresh only implements the drop-down function, but not the pull-up function. This section describes how to integrate pull-down refresh and pull-up to load more class libraries. EGOTableViewPullRefresh
Class Library: https://github.com/emreberge/EGOTableViewPullRefresh
Demo effect included
650) this. width = 650; "src =" http://img.blog.csdn.net/20130602183634265 "_ xhe_src =" http://img.blog.csdn.net/20130602183634265 "style =" max-width: 98%; "/> 650) this. width = 650; "src =" http://img.blog.csdn.net/20130602183639031 "_ xhe_src =" http://img.blog.csdn.net/20130602183639031 "style =" max-width: 98%; "/>
Whats different on this fork:
-
Easy to integrate. Use interface builder to add tableView for configuration.
-
Easy configuration: Arrow portraits, background colors, and text colors can be easily changed through the properties of the PullTableView class.
-
Pull up to load more data functions at the bottom of the Table.
-
You can use code modifications to refresh and load more animations.
The fast setup:
-
Add QuartzCore. framework to your project.
-
Drag EGOTableViewPullRefresh to your project directory.
-
View the available properties of the PullTableView. h file.
-
Add a PullTableView to your code to implement the PullTableViewDelegate delegate method.
-
Enjoy it.
The detailed setup (Walk through for creating the demo project ):
-
Create a new xcode Project
-
Select View Based Application Template (xcode 4.2 and later versions are Single View Application templates)
-
Project name: EGOTableViewPullRefreshDemo
-
Create the EGOTableViewPullRefreshDemoViewController class under the project file (this step is not required for the Single View Application template)
-
Add QuartzCore. framework to the Project
Add PullTableView to the project:
Add the PullTable view to EGOTableViewPullRefreshDemoViewController. xib:
-
Drag a UITableView control to the View.
-
Enable Identity inspector to change the inheritance class of Table from UITableView to PullTableView.
-
Connect the dataSources data source and the pullDelegate protocol to the File's owner of the PullTableView.
Configure the header file EGOTableViewPullRefreshDemoViewController. h:
-
Add # import "PullTableView. h"
-
Declare the PullTableViewDelegate and UITableViewDataSource protocols
-
Create an output port named pullTableView to connect to tableView ON interface Builder.
Configure the View Controller and footer EGOTableViewPullRefreshDemoViewController. m
#pragma mark - Refresh and load more methods- (void) refreshTable{ /* Code to actually refresh goes here. */ self.pullTableView.pullLastRefreshDate = [NSDate date]; self.pullTableView.pullTableIsRefreshing = NO;}- (void) loadMoreDataToTable{ /* Code to actually load more data goes here. */ self.pullTableView.pullTableIsLoadingMore = NO;}#pragma mark - UITableViewDataSource- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 5;}- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 10;}- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *cellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if(!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; } cell.textLabel.text = [NSString stringWithFormat:@"Row %i", indexPath.row]; return cell;}- (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ return [NSString stringWithFormat:@"Section %i begins here!", section];}- (NSString *) tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{ return [NSString stringWithFormat:@"Section %i ends here!", section];}#pragma mark - PullTableViewDelegate- (void)pullTableViewDidTriggerRefresh:(PullTableView *)pullTableView{ [self performSelector:@selector(refreshTable) withObject:nil afterDelay:3.0f];}- (void)pullTableViewDidTriggerLoadMore:(PullTableView *)pullTableView{ [self performSelector:@selector(loadMoreDataToTable) withObject:nil afterDelay:3.0f];}
self.pullTableView.pullArrowImage = [UIImage imageNamed:@"blackArrow"];self.pullTableView.pullBackgroundColor = [UIColor yellowColor];self.pullTableView.pullTextColor = [UIColor blackColor];
if(!self.pullTableView.pullTableIsRefreshing) { self.pullTableView.pullTableIsRefreshing = YES; [self performSelector:@selector(refreshTable) withObject:nil afterDelay:3];}