2

我使用EGOTableViewPullRefresh 在我的tableView. 我添加了一个UIBarButtonItem可以(IBAction)refreshBtnClicke调用EGORefreshTableHeaderView.hrefreshByClickRegreshBtn:中的自定义方法来显示并重新加载我的EGORefreshTableHeaderViewtableView

表视图控制器.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,将永远不会出现,即使被调用。任何帮助表示赞赏:)EGORefreshTableHeaderViewUIBarButtonItemrefreshByClickRegreshBtn:

4

1 回答 1

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];
}
}
于 2012-07-20T13:31:44.317 回答