iOS下拉刷新上拉加载更多EGOTableViewPullRefresh类库

发布时间:2020-07-06 07:32:18 作者:新风作浪
来源:网络 阅读:5827

   在一个项目开发过程中为了更好的体验经常会用到下拉刷新更新数据,当然也伴随一些上拉加载更多数据的情况;当前比较火的EGOTableViewPullRefresh只实现了下拉功能,而没有上拉的功能。这里介绍一个同时集成下拉刷新和上拉加载更多的类库EGOTableViewPullRefresh

英文原文和类库下载地址:https://github.com/emreberge/EGOTableViewPullRefresh


附带 Demo效果

iOS下拉刷新上拉加载更多EGOTableViewPullRefresh类库iOS下拉刷新上拉加载更多EGOTableViewPullRefresh类库



Whats different on this fork:





The fast setup:

The detailed setup (Walk through for creating the demo project):

添加 PullTableView 到工程里:

添加 PullTable 视图到 EGOTableViewPullRefreshDemoViewController.xib上:


配置视图控制器的头文件 EGOTableViewPullRefreshDemoViewController.h:

配置视图控制器和页脚 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 p_w_picpathNamed:@"blackArrow"];
self.pullTableView.pullBackgroundColor = [UIColor yellowColor];
self.pullTableView.pullTextColor = [UIColor blackColor];

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》