Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView dragging distance with UIRefreshControl

I'm having some trouble on implementing a UIRefreshControl on a UITableView.

Everything is working fine except the fact that I have to scroll something like 80% of the screen for the UIRefreshControl to get triggered. Sometimes I'm not even able to trigger it since there is a tab bar on the bottom of the screen, which cancels the scrolling movement when the finger reaches it.

I've looked at other apps, namely Apple's 'Mail', where the UIRefreshControl is triggered after scrolling only 30% of the screen.

What am I missing? Really need help on this one!

Thanks in advance

like image 719
Joaocdn Avatar asked May 03 '13 14:05

Joaocdn


2 Answers

I had a similar problem and it's quite possible that's the same cause for you. For me happens that I hided the scroll indicator making me unable to see the obvious cause of the problem: the UIScrollView's height is much greater than its superView...

Double check your UIScrollView's height because the "dragging distance" it's just a percentage of that height. Same goes for UITableView too, since it's a child class of UIScrollView.

EDIT: Seems that this isn't the only way to reproduce this problem, since the required drag distance to trigger the refresher is calculated in a buggy way. Refer to this question for more info.

But in general it will happen if your UIScrollView's height is different than his parent container (e.g the screen itself).

like image 161
kbtz Avatar answered Oct 26 '22 23:10

kbtz


You probably need to not use UIRefreshControl and just utilize scrollViewDidScroll (or tableViewDidScroll if a tableView) on handle your refresh accordingly since UIRefreshControl can't be modified.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if ((scrollView.contentOffset.y + scrollView.frame.size.height) >=    scrollView.contentSize.height)
    {
        // Refresh from here
    }
}
like image 32
Mark McCorkle Avatar answered Oct 27 '22 00:10

Mark McCorkle