Sephiroth87 / ODRefreshControl

A pull down to refresh control like the one in Apple's iOS6 Mail App
MIT License
2.15k stars 385 forks source link

A quick scroll will lead to refresh unpurposely #33

Open ipeisong opened 11 years ago

ipeisong commented 11 years ago

In iOS 6 mail, only when your finger keep staying on screen to pull will trigger the refresh, which is the correct behavior.

This control is great, but my users complain very often they just scroll from bottom to top with a high acceleration, the refresh will also be trigger. Can fix this? Cos this also add more burden to server actually. Thanks.

Sephiroth87 commented 11 years ago

I'll work on it, thanks :)

sjapps commented 11 years ago

Looking forward to this fix as well.

Sephiroth87 commented 11 years ago

It should be fixed, but as usual, a round of double checking will be appreciated :)

sjapps commented 11 years ago

Works good! Thank you!

Unrelated to this but since I have your attention, I added [self.scrollView scrollRectToVisible:CGRectMake(0, 0, 1, kOpenedViewHeight) animated:YES ]; to line 418. Basically when I manually call beginRefreshing, it doesn't it down automatically without scrollrecttovisible. I'm sure there is another way

Sephiroth87 commented 11 years ago

It's not supposed to show the control when using beginRefreshing (see UIRefreshControl for reference). If you want, you can simply put that line after the call to beginRefreshing

sjapps commented 11 years ago

Maybe I misunderstood the purpose of beginRefreshing but whats the point of calling it if you can't see the loading indicator?

Sephiroth87 commented 11 years ago

Well, I'm not entirely sure, but I made it so it's consistent with Apple's implementation... I think it's just for when you have more than one way to trigger the refresh, like a button, so you can't trigger it twice...

thorar commented 11 years ago

Thanks for such a great component. I tried to achieve the same behaviour of SJApps (i.e. on beginRefresh, I'd like to animate-to-display the activity view). I tried with scrollRectToVisible:CGRectMake and in several other ways. Just wanted to let you know that they only way it works for me is by adding 1 pixel to the scroll height:

[self.scrollView scrollRectToVisible:CGRectMake(0, 0, 1, kOpenedViewHeight+1) animated:YES];

All other attempts (and there were many!) failed. Incidentally, I was thinking that beginRefresh:animate:BOOL and endRefresh:animate:(BOOL) could be added to the API.

Thanks!

Sephiroth87 commented 11 years ago

Thank you :)

I have to say, I actually have no idea how that could work, since you are not scrolling where the control is, but below it...

I'm pretty sure this works just fine, unless you are doing something strange somewhere else :P

[refreshControl beginRefreshing]; [self.scrollView setContentOffset:CGPointMake(0, -44) animated:YES];

nestserau commented 11 years ago

Now, if you tap the status-bar to scroll to top and then start pulling the table, the refresh control doesn't appear.

nestserau commented 11 years ago

For myself I fixed it simply by adding:

...CGFloat offset = [[change objectForKey:@"new"] CGPointValue].y + self.originalContentInset.top;
if (_lastOffset == 0) {
    _canRefresh = YES;
}

if (_refreshing) {...