使用EGOTableViewPullRefresh更新表

时间:2011-06-15 09:53:23

标签: uitableview ios4

我正在使用plist文件来填充我的表格单元格,现在我添加了EGOTableViewPullRefresh API来更新我的单元格,但我不知道如何将我的plist url文件与此API匹配

//this is my plist code that load from server 
     NSURL *url = [NSURL URLWithString:@"http://example.com/news.plist"];
     titles = [[NSArray arrayWithContentsOfURL:url] retain];

已编辑:

#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;
    [self.tableView reloadData];  

}

- (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

}

1 个答案:

答案 0 :(得分:5)

您应该可以致电reloadData,这将刷新您的dataSource。对于“拉动刷新”功能,此逻辑应该相同。