zoukankan      html  css  js  c++  java
  • EGORefreshTableHeaderView学习 沧海一粟

    1、下载EGORefreshTableHeaderView开源框架。

    2、往应用中添加EGORefreshTableHeaderView.h文件、EGORefreshTableHeaderView.m文件、Resource目录,并且导入QuartzCore.framework

    3、添加代码

     往tableview对应的类的头文件中添加如下代码 EGORefreshTableHeaderView *_refreshHeaderView;

            BOOL _reloading;  
          
        - (void)reloadTableViewDataSource;  
        - (void)doneLoadingTableViewData;  
    
     
    

     往viewDidLoad函数里添加如下代码

        if (_refreshHeaderView == nil) {  
                  
                EGORefreshTableHeaderView *view = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.tableView.bounds.size.height, self.view.frame.size.width, self.tableView.bounds.size.height)];  
                view.delegate = self;  
                [self.tableView addSubview:view];  
                _refreshHeaderView = view;  
                [view release];  
                  
            }  
              
            //  update the last update date  
            [_refreshHeaderView refreshLastUpdatedDate];  
    

      再添加一些事件函数

        #pragma mark -  
        #pragma mark Data Source Loading / Reloading Methods  
          
        - (void)reloadTableViewDataSource{  
              
            //  should be calling your tableviews data source model to reload  
            //  put here just for demo  
            _reloading = YES;  
              
        }  
          
        - (void)doneLoadingTableViewData{  
              
            //  model should call this when its done loading  
            _reloading = NO;  
            [_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.tableView];  
              
        }  
          
        #pragma mark -  
        #pragma mark UIScrollViewDelegate Methods  
          
        - (void)scrollViewDidScroll:(UIScrollView *)scrollView{  
              
            [_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];  
              
        }  
          
        - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{  
              
            [_refreshHeaderView egoRefreshScrollViewDidEndDragging:scrollView];  
              
        }  
          
        #pragma mark -  
        #pragma mark EGORefreshTableHeaderDelegate Methods  
          
        - (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view{  
              
            [self reloadTableViewDataSource];  
            [self performSelector:@selector(doneLoadingTableViewData) withObject:nil afterDelay:3.0];  
              
        }  
          
        - (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view{  
              
            return _reloading; // should return if data source model is reloading  
              
        }  
          
        - (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view{  
              
            return [NSDate date]; // should return date data source was last changed  
              
        }  
    

     最后,自己配置数据源进行测试。

  • 相关阅读:
    nginx+vue+thinkphp5.1部署,解决前端刷新404,以及前端404解决后,后台又404的问题
    centos7.4挂载硬盘
    thinkphp5.1+layui2.x 时间戳转换为日期格式
    解决linux(ubuntu18)下无法挂载ntfs磁盘,并读写挂载硬盘
    sublime中nodejs配置
    jquery 中的$("obj").html('')中的html动态改变之后点击事件失效
    js怎么弹出变量的数据类型
    异步操作执行后子页面重新修改父页面iframe高度
    iframe标签父页面高度自适应
    string.Format()方法、Graphics类、DrawImage方法
  • 原文地址:https://www.cnblogs.com/taintain1984/p/2834074.html
Copyright © 2011-2022 走看看