zoukankan      html  css  js  c++  java
  • EGORefreshTableHeaderView下拉刷新

    - (void)viewDidLoad {
        [super 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];
    
    	
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    	return YES;
    }
    
    
    #pragma mark -
    #pragma mark UITableViewDataSource
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 10;
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return 4;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        
        static NSString *CellIdentifier = @"Cell";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }
        
    	// Configure the cell.
    
        return cell;
    }
    
    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    	
    	return [NSString stringWithFormat:@"Section %i", section];
    	
    }
    
    
    #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
        NSLog(@"reloadTableViewDataSource");
    	_reloading = YES;
    	
    }
    
    - (void)doneLoadingTableViewData{
    	
    	//  model should call this when its done loading
    	_reloading = NO;
        NSLog(@"doneLoadingTableViewData");
    //    结束当前刷新
    	[_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.tableView];
    	
    }
    
    
    #pragma mark -
    #pragma mark UIScrollViewDelegate Methods
    //上滑下滑都会调用当前的scrollview 所以必须判断是否需要刷新
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView{	
    	
         NSLog(@"scrollViewDidScroll");
    	[_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];
       
    		
    }
    
    - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    	
        NSLog(@"scrollViewDidEndDragging");
    	[_refreshHeaderView egoRefreshScrollViewDidEndDragging:scrollView];
        
    	
    }
    
    
    #pragma mark -
    #pragma mark EGORefreshTableHeaderDelegate Methods
    //下拉结束上滑的时候调用此函数
    - (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view{
    	NSLog(@"egoRefreshTableHeaderDidTriggerRefresh");
        //在这里改变_reloading 不然会一直调用此过程
    	[self reloadTableViewDataSource];
        //调用doneLoadingTableViewData ,在这个函数里再改变_reloading,让其可以重新实现下拉刷新
    	[self performSelector:@selector(doneLoadingTableViewData) withObject:nil afterDelay:3.0];
    	
    }
    //当返回no的时候就会刷新数据 当拖拽的时候就会调用此函数,当返回yes的时候egoRefreshTableHeaderDidTriggerRefresh就不会被调用
    
    - (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view{
    	NSLog(@"egoRefreshTableHeaderDataSourceIsLoading");
    	return _reloading; // should return if data source model is reloading
    	
    }
    
    - (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view{
    	NSLog(@"egoRefreshTableHeaderDataSourceLastUpdated");
    	return [NSDate date]; // should return date data source was last changed
    	
    }
    
    
    #pragma mark -
    #pragma mark Memory Management
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
    }
    
    - (void)viewDidUnload {
    	_refreshHeaderView=nil;
    }
    
    - (void)dealloc {
    	
    	_refreshHeaderView = nil;
        [super dealloc];
    }
    

      

  • 相关阅读:
    Google TensorFlow 机器学习框架介绍和使用
    Linux下chkconfig命令详解转载
    wireshark----linux
    linux 开机自启转载
    linux 开机自启
    linux 开机自启脚本
    当进行make命令学习是出现error trying to exec 'cc1': execvp: No such file or directory
    centos6.4安装GCC
    安装cmake
    整型数转字符串
  • 原文地址:https://www.cnblogs.com/AbelChen1991/p/3675609.html
Copyright © 2011-2022 走看看