我正在使用EGOTableViewPullRefresh来获取tableView
中的提升效果。我添加了UIBarButtonItem
(IBAction)refreshBtnClicke
,可以在 EGORefreshTableHeaderView.h 中调用自定义方法refreshByClickRegreshBtn:
来显示EGORefreshTableHeaderView
并重新加载tableView
1}}
TableViewController.m
-(IBAction)refreshBtnClicked{
[_refreshHeaderView refreshByClickRegreshBtn:self.tableView];
}
EGORefreshTableHeaderView.h
- (void)refreshByClickRegreshBtn:(UIScrollView *)scrollView{
[self setState:EGOOPullRefreshLoading];
NSLog(@"scrollView.contentInset.top :%f", scrollView.contentInset.top);// it's always 0 here
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
[scrollView setContentInset:UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f)];
[UIView commitAnimations];
if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDidTriggerRefresh:)]) {
[_delegate egoRefreshTableHeaderDidTriggerRefresh:self];
}
}
问题:如果tableView
中没有数据,EGORefreshTableHeaderView
将始终在UIBarButtonItem
点击后显示。但是,一旦下载的数据填满tableView
,即使EGORefreshTableHeaderView
被调用,我再次点击UIBarButtonItem
也不会出现refreshByClickRegreshBtn:
。任何帮助表示赞赏:)
答案 0 :(得分:1)
通过将[scrollView setContentInset:UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f)]
替换为[scrollView setContentOffset:CGPointMake(0, -60)]
来解决问题。
- (void)refreshByClickRegreshBtn:(UIScrollView *)scrollView{
[self setState:EGOOPullRefreshLoading];
NSLog(@"scrollView.contentInset.top :%f", scrollView.contentInset.top);// it's always 0 here
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
//[scrollView setContentInset:UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f)];
[scrollView setContentOffset:CGPointMake(0, -60)];
[UIView commitAnimations];
if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDidTriggerRefresh:)]) {
[_delegate egoRefreshTableHeaderDidTriggerRefresh:self];
}
}