简体   繁体   中英

EGORefreshTableHeaderView not properly working on iOS 5.1

I am using the EGORefreshTableHeaderView [1] to fetch new data from a server into a UITableView.

This works pretty good but in iOS 5.1 the EGORefreshTableHeaderView does not scroll back into the intended height when the user releases the pull down. Normally it should scroll back to an contentInset of 60px. Then the loading view should be visible for the time which the loading process takes and after that scroll back to 0px inset.

The first scroll-back should happen in the egoRefreshScrollViewDidEndDragging:scrollView method.

    - (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView {

    BOOL _loading = NO;
    if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) {
        _loading = [_delegate egoRefreshTableHeaderDataSourceIsLoading:self];
    }

    if (scrollView.contentOffset.y <= - 65.0f && !_loading) {

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


        [self setState:EGOOPullRefreshLoading];
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.2];
        scrollView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);
        [UIView commitAnimations];


        //I've also tried it with block animations! But doesn't work!
        /*[UIView animateWithDuration:0.2 animations:^{
         scrollView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);

         }];*/
    }

}

The problem is that when a user releases the scroll view on the half of the screen (shown in the screenshot below), the scrollview does not bounce back into the 60px inset where it should reload the data.

My first idea was that it is because of the animations. So I changed it to block animations but nothing changes. I guess the problem is that the animations are not executed on commitAnimations rather at the end of the loading.

问题的屏幕截图

Does anyone have a solution for this?

[1]... https://github.com/enormego/EGOTableViewPullRefresh

I would pull up their demo application and follow their delegate methods.

put this inside didEndDragging:

[_delegate egoRefreshScrollViewDidEndDragging:scrollView];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM