0

我有一个关于使用的问题EGORefreshTableHeaderView

如果我使用这段代码,没关系:

 - (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView *)view  
{
    _reloading = YES; 
    [self performSelector:@selector(refreshData) withObject:nil afterDelay:0.1f];
}

 - (void)refreshData
{
    _reloading = NO;
   [self.dataSourceArr removeAllObjects]; 
   [self.dataSourceArr addNewData];
   [self.egoHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.mainTableView];
   [self.mainTableView reloadData];
}

但是,当我使用此代码时,它EGOrefreshHeaderView会一直显示在mainTableView顶部,它不会隐藏:

 - (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView *)view  
{
    _reloading = YES; 
    [self refreshData];
}
 - (void)refreshData
{
    _reloading = NO;
   [self.dataSourceArr removeAllObjects]; 
   [self.dataSourceArr addNewData];
   [self.egoHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.mainTableView];
   [self.mainTableView reloadData];
}
4

1 回答 1

1

最上面的代码是这样运行的:

// someone calls egoRefreshTableHeaderDidTriggerRefresh
    [_delegate egoRefreshTableHeaderDidTriggerRefresh:self]
        // sets up a refreshData to run after set period of time
    scrollView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);  // a
// some time later, refreshData runs
    [self.egoHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.mainTableView];
        [scrollView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)];  // b

底部位运行如下:

// someone calls egoRefreshTableHeaderDidTriggerRefresh
    [_delegate egoRefreshTableHeaderDidTriggerRefresh:self]
        [self refreshData];
            [self.egoHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.mainTableView];
                [scrollView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)];  // b
    scrollView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);  // a

线ab被颠倒。即使更改是动画的,第二行也会覆盖第一行。

修复1:

修改文件EGORefreshTableHeaderView.h

更改- (void)egoRefreshTableHeaderDidTriggerRefresh:...- (bool)egoRefreshTableHeaderDidTriggerRefresh:...

修改文件EGORefreshTableHeaderView.m

改变- (void)egoRefreshScrollViewDidEndDragging:

if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDidTriggerRefresh:)]) {
    if([_delegate egoRefreshTableHeaderDidTriggerRefresh:self]) {
       return;
    }
}

最后改变你的egoRefreshTableHeaderDidTriggerRefresh:

- (bool)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView *)view  
{
    _reloading = YES; 
    [self refreshData];
    return true;
}

修复 2:

如果您不想更改第三方代码,顶级版本是唯一的方法。您可以将持续时间指定为 0,这应该将选择器排入队列以在之后运行。

于 2013-07-05T07:04:18.890 回答