soffes / sspulltorefresh Goto Github PK
View Code? Open in Web Editor NEWSimple and highly customizable pull to refresh view
License: MIT License
Simple and highly customizable pull to refresh view
License: MIT License
Hello @samsoffes !
At first, thank you for your library! It's really simple ti use =)
I'm using this lib in my current project and have question about refreshing lastUpdatedAt. I found comment to pullToRefreshViewLastUpdatedAt:
method:
... This will get called when it finishes loading...
So, I assume that my delegate should receive this method after I call [self.pullToRefreshView finishLoading];
but it doesn't wirk now.
Now I've implemented one more method in my delegate to manually ask pulltoRefresh to refresh date:
- (void)pullToRefreshViewDidFinishLoading:(SSPullToRefreshView *)view {
[view refreshLastUpdatedAt];
}
But maybe better to ask delegate for lastUpdatedAt date when we finish loading?
I will be glad to send you a pull request if you agree with it =)
Thanks
I think it need set one lock when pull to refresh, or else , it get repeat records from server.
Currently, you have to call removeFromSuperview
to prevent a KVO leak. This happens because the weak reference to the scroll view gets nil'd out before SSPullToRefresh can remove it's observer.
Here's my StackOverflow question on the issue: http://stackoverflow.com/questions/10793206/how-do-you-remove-kvo-from-a-weak-property
Any help would be greatly appreciated!
Getting the following error very rarely with no other information:
Exception Type: SIGSEGV Code: SEGV_ACCERR
Stack:
SSPullToRefreshView.m line 207
+[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:animations:start:completion:] + 508
+[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 60
SSPullToRefreshView.m line 206
You need to change the end of the observeValueForKeyPath body so that expanded isn't always passed true, e.g.
BOOL expand = YES;
// Ask the delegate if it's cool to start loading
if ([_delegate respondsToSelector:@selector(pullToRefreshViewShouldStartLoading:)]) {
if (![_delegate pullToRefreshViewShouldStartLoading:self]) {
// Animate back to normal since the delegate said no
newState = SSPullToRefreshViewStateNormal;
expand = NO;
}
}
// Animate to the new state
[self _setState:newState animated:YES expanded:expand completion:nil];
Hi,
What about Swift compatibility? it works fine?
Hi, I think this repo is very good.Does it have pull up to load more control ?
Hi Sam,
When SSPullToRefreshView's -finishLoading is called, SSPullToRefreshView's calls the delegate method -pullToRefreshViewDidFinishLoading before the animation is finished.
It would be very convenient to have a delegate method that is called after the animation has finished.
Thanks for your great work,
Laurin
Any idea why I might be getting:
-[SSPullToRefreshView _update]: unrecognized selector sent to instance 0xd0ca5a0
at this line in viewDidLoad:
self.refreshControl = [[SSPullToRefreshView alloc] initWithScrollView:self.tableView delegate:self];
Thanks!
There's a visual glitch when the table have headers in sections.The header view don't float to the top of the table when pull to refresh is active.
Programatic invocations of startLoading
should not cause the delegate method pullToRefreshViewDidStartLoading:
to be called. This should only be called on user-initiated events.
The example in SSPullToRefreshView.h is a good example of this issue:
- (void)refresh {
[self.pullToRefreshView startLoading];
// Load data...
[self.pullToRefreshView finishLoading];
}
- (void)pullToRefreshViewDidStartLoading:(SSPullToRefreshView *)view {
[self refresh];
}
Consider the following scenario given the above code:
viewDidAppear:
refresh
is called to trigger a first loadstartLoading
is called so that the refresh control reflects the current loading statepullToRefreshViewDidStartLoading:
is called during the state transitionrefresh
is called againSSPullToRefreshView
prevents that from continuing in an infinite loop, but I now have multiple instances of refresh
running for what should have been a single invocation.
The only way I have found around this is to override startLoading
and wrap the call to super
by temporarily removing the delegate
. Alternatively, any consumer is required to track loading state to prevent a single invocation of refresh
from firing multiple loads.
Hi,
I'm looking for a way to programmatically show the refresh control so it's visible when opening my view controller. Any way to do this? I couldn't find any yet.
Thanks!
Hi, @soffes.
First of all, I must say I've been using SSPullToRefresh
for quite some time now and I love it. Thanks for a great component.
Recently, I ran into an issue, though. I tried attaching SSPullToRefresh
to a UITableView
that displays sectionIndexTitles
(the index on the right side, for quickly navigation between sections).
Everything works as usual, but when SSPullToRefresh
starts loading and the table contentInset
is adjusted in _setContentInsetTop:
, the positioning of index titles is affected, making the menu jump up and down. Although this happens only once per refresh, it doesn't make up for a great user experience.
Is there a known or proposed solution to make things work with tableViews
displaying sectionIndexTitles
?
It should be replaced with NSTextAlignmentCenter to silence the compiler warning.
I have a strange performance in the header animation.
When the number of cells are few, eg five, the animation is strange.The header automaticly jumps up and after makes the down animation and up again.
Thanks
Hey folks, thanks a bunch for this its been super useful.
Just wondering what I need to do to get this working with iOS 7?
After SSPullToRefresh finishes loading it seems to mess with (reduces?) the height of the scrollView.
I see in 1.2.2, the call that clamped the scroll progress to < 1.0 is gone, but it still isn't being sent. In the KVO callback, the setProgress:
call doesn't happen if the state is .Ready
, which it is if the offset is greater than the expanded height. Not sure what the best solution is.
It is still functional but the whole view turn to white
I'm using a custom view that conforms to SSPullToRefreshContentView, if that makes a difference. But when I drag downward until the state is SSPullToRefreshViewStateReady, and release the touch from a static velocity (i.e. don't "fling" the scrollview downward) the content view seems to instantly shift upward by about 20px before smoothly transitioning to the correct content inset. For me, using UIScrollView delegate methods instead of KVO solves the problem. Might be something to look into.
In our current project we decided to show time as last updated at
because we think that it's more useful than just a date. We could refresh timeline lots of times a day.
So I've implemented it by adding subclass for SSPullToRefreshDefaultContentView
with one redefined method:
- (void)setLastUpdatedAt:(NSDate *)date withPullToRefreshView:(SSPullToRefreshView *)view {
static NSDateFormatter *dateFormatter = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"HH:mm:ss";
});
self.lastUpdatedAtLabel.text = [NSString stringWithFormat:
@"Last Updated: %@",
[dateFormatter stringFromDate:date]];
}
It works and everything is fine =) I just would like to give a propose to change default implementation also to show time instead of date.
@samsoffes I will be happy to send you a pull request if you will apply this idea =)
thanks)
Since initWithScrollView:delegate:
is a de-facto designated initializer it should call designated initializer of superclass with super
, not self
Explicitly stating that it's a designated initializer with NS_DESIGNATED_INITIALIZER would be nice.
Hi, first of all nice work around this!
I am using SSPullToRefresh in one of my projects, but now i face a simple problem, i want to disable the refresh for a moment ( view in edit mode ) and i can't view the way to do it.
Any suggestions?
Regards from Portugal.
I’ve recently added SSPullToRefresh to the CocoaPods package manager repo.
CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.
However, sspulltorefresh doesn't have any version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.
Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.
In case you didn’t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:
$ git tag -a 1.0.0 -m "Tag release 1.0.0"
$ git push --tags
I was raging all day (still am) on a very weird UICollectionView animation bug.
As a side project, I realized that our pull-to-refresh has been shoved under our navigationbar (which animates in and out - which is causing the animation bug, incidentally).
At first I was like awww wtf, who is messing with the insets what's going on!? (having been raging for so long, it was impossible to turn off). SSPullToRefresh
!? Bah!
Dropped into the code, saw defaultContentInset
, set it to the new values, and shit just works.
👏 👏 👏
Nice work. Thanks for, at least, making the end of my day enjoyable. Tomorrow I have to get back to fixing this animation thing, but that's another day!
There's an issue with [self.pullToRefreshView startLoadingAndExpand:YES];
method, in that if you have more cells than fit on the screen, when this method is called the header animates down, but the pull to refresh view stays put.
If you manually pull down then the animation sorts itself out.
The standard UIRefreshControl triggers refresh when a user swipes down with three fingers while the content is already scrolled to top.
VoiceOver users would expect the same behavior from SSPullToRefresh control.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.