SVPullToRefresh icon indicating copy to clipboard operation
SVPullToRefresh copied to clipboard

Pull to Refresh activates Infinite Scrolling

Open sabernar opened this issue 11 years ago • 10 comments

My set up is very simple:

__weak MyClass *weakSelf = self;
[self.tableView addPullToRefreshWithActionHandler:^{
    [weakSelf refreshPollData];
}];

[self.tableView addInfiniteScrollingWithActionHandler:^{
    [weakSelf loadMorePollData];
}];

Infinite Scrolling gets called even though only Pull to Refresh should be called. Could this be because I don't have many rows in my table?

sabernar avatar Apr 03 '13 22:04 sabernar

Hmm yeah that could be. I thought this was fixed a while ago, I'll try to give it another look soon.

samvermette avatar Apr 06 '13 22:04 samvermette

Yes, I encountered the same problem when number of cell in a tableview, say 1, is small.

Tony091250147 avatar Apr 11 '13 02:04 Tony091250147

Issue #96

yimingtang avatar Apr 11 '13 05:04 yimingtang

The fix: showsInfiniteScrolling should initially be set to NO if the scroll view's content height is lesser than its frame. If anyone wants to jump ahead and make a pull request for this, would be much appreciated.

samvermette avatar Apr 11 '13 20:04 samvermette

all if we set showsInfinitsScrolling to NO but if we want drag to load more data how handle to visible the infinite view?

anhuijhy avatar Dec 03 '13 15:12 anhuijhy

my solution: 1、when view did appear: add pull and infinities action handler and trigger refresh action. 2、after pull refresh callback , invite: [self.tableView showsInfiniteScrolling]; 3、change the showsInfiniteScrolling method as follow: // return !self.infiniteScrollingView.hidden; return self.showsInfiniteScrolling = self.contentSize.height < self.frame.size.height ? NO : YES;

libinliu2013 avatar Dec 29 '13 07:12 libinliu2013

+1. @anhuijhy brings up a good point. Sometimes the initial list may be small. e.g. "Get all the results since yesterday" has no guaranteed length -- but we'd still want the infinite scroll enabled if we wanted each "up swipe" to load the previous day's results.

Any way to differentiate between the two swipe types (up vs. down) if the view is shorter than the frame?

nwhittaker avatar Jan 20 '14 20:01 nwhittaker

Check if the scrollView.contentOffset.y greater than 0 before changing state work for me. In UIScrollView+SVInfiniteScrolling.m:

  • (void)scrollViewDidScroll:(CGPoint)contentOffset { if(self.scrollView.contentOffset.y > 0 && self.state != SVInfiniteScrollingStateLoading && self.enabled) { ... }

siliconprime-duc avatar Oct 03 '14 08:10 siliconprime-duc

PR #245 has @siliconprime-duc 's fix in case this project is still alive :bow:

esttorhe avatar Mar 22 '15 01:03 esttorhe

I think #260 fixes this.

esttorhe avatar May 13 '16 16:05 esttorhe