gpt4 book ai didi

iOS UITableView headerView 没有隐藏

转载 作者:行者123 更新时间:2023-11-29 03:47:51 24 4
gpt4 key购买 nike

我对 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];
}

最佳答案

代码的顶部部分运行如下:

// 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,这样选择器就会排队等待运行。

关于iOS UITableView headerView 没有隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17481653/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com