m1entus / inspulltorefresh Goto Github PK
View Code? Open in Web Editor NEWA simple to use very generic pull-to-refresh and infinite scrolling functionalities as a UIScrollView category.
License: MIT License
A simple to use very generic pull-to-refresh and infinite scrolling functionalities as a UIScrollView category.
License: MIT License
AController ->push ->BController(INSPullToRefresh)
when BController poped, error happened.
error log
..UICollectionView was deallocated while key value observers were still registered with it...
Maybe, Here is the cause.
- (void)resetScrollViewContentInsetWithCompletion:(void(^)(BOOL finished))completion {
[UIView animateWithDuration:INSPullToRefreshDefaultResetContentInsetAnimationTime
delay:0
options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState)
animations:^{
[self setScrollViewContentInset:self.externalContentInset];
}
completion:completion];
}
- (void)setScrollViewContentInset:(UIEdgeInsets)contentInset {
BOOL alreadyUpdating = _updatingScrollViewContentInset; // Check to prevent errors from recursive calls.
if (!alreadyUpdating) {
self.updatingScrollViewContentInset = YES;
}
self.scrollView.contentInset = contentInset;
if (!alreadyUpdating) {
self.updatingScrollViewContentInset = NO;
}
}
In the case of the following settings, the problem does not occur.
Of course animation does not move.
INSPullToRefreshDefaultResetContentInsetAnimationTime = 0.0
ScrollToTopAfterEndRefreshing is disabled.
collectionView.ins_addPullToRefreshWithHeight(60, handler: { (scrollView) -> Void in
self.delegate?.pageCollectionViewControllerRefresh()
})
let pullToRefresh = INSDefaultPullToRefresh(frame: CGRectMake(0, 0, 24, 24), backImage: UIImage(named: "circleLight"), frontImage: UIImage(named: "circleDark"))
collectionView.ins_pullToRefreshBackgroundView.scrollToTopAfterEndRefreshing = false
collectionView.ins_pullToRefreshBackgroundView.delegate = pullToRefresh
collectionView.ins_pullToRefreshBackgroundView.addSubview(pullToRefresh)
If I leave my table view while loading is in progress (e.g. by pushing), and come back to it, the INSPullToRefreshBackgroundView appears in a wrong state, like it has added additional inset to the top of the scrollview.
I could not find a good solution for now in the INSPullToRefreshBackgroundView class, but the issue is linked to KVO happening while the view is offscreen.
For now, I change the enable property of the INSPullToRefreshBackgroundView instance in my viewWillDisappear and viewWillAppear, but it is kind of strange to see the loading indicator disappear/reappear.
App starts up and trigger pull to refresh automatically immediately, when data load finishes, sometimes tableView(or scrollView) can not return to its original position(that is, the contentOffset.y is not zero), maybe this problem is from INSPullToRefreshBackgroundView's member externalContentInset's value is not zero(equals to 60.0 when displays not correctly), this problem occurs more frequently when device is iPhone 4S and system version iOS7, can you help to solve this problem? thanks.
In one of my complex view controllers, independent methods decide to start or end the refresh animation. Sometimes this happens in sequential calls in the same run loop. In these cases, the call in the dispatch_async block of the beginRefreshing method gets called after method endRefreshing has been called.
can you plz add load more for both table and collerciton view
First off, this is one of the best implementations I've seen of pull-to-refresh, very configurable and it works well. Great work. I am however experiencing what I think is a bug.
Basically, while refreshing a table view that uses section views, the pull-to-refresh view disappears when scrolling through the table. See my images below:
While loading I scroll through the table and the Pull-to-refresh view scrolls with the table while the section headers stop scrolling at the contentInset:
Is there a way to pin the pull-to-refresh view to the top of the table, rather than have it scroll with the table? I think this is the simplest solution. The alternative is to alter the contentInset while scrolling which would ensure the section headers scroll all the way to the top of the table. If you could help me out, that would be great and I can go ahead and implement this component in the rest of the app.
If the user initiates an update and then pushes into a new view controller, then endRefresh is called, then the user pops back to the table view, the content offset is permanently messed up.
It looks like dropping back to the table view adds to the top value of externalContentInset when doing this navigation, leaving the table view in a bad state.
I met some weird behavior when app launches and automatically pulls to refresh, after refresh finishes, there is a padding at the top of the tableView(the padding height equals to pullToRefreshBackgroundView's height that initialized with ins_addPullToRefreshWithHeight:handler method), and my expected result is no padding exists after refresh.
I find some cases as below:
Please check the contentOffset or contentInset when finish pull to refresh, and this weird behavior, thanks!
After add ins_addPullToRefreshWithHeight....
to tableview there is problem, when slowly pull down tableview. Content inset is reverted to value before pull and pull-to-refresh is invisible.
There is no issue when pull to refresh i pulled down really fast.
Founded solution is in method - (void)setState:(INSPullToRefreshBackgroundViewState)newState
remove [self setScrollViewContentInsetForLoadingAnimated:YES];
to prevent reset default inset for tableview.
if use FBKVOController, we should not write 'ins_removeInfinityScroll' or 'ins_removePullToRefresh' in 'dealloc' method
Here's how to reproduce:
Repeating these steps will make it go lower and lower.
A quick solution for me was to disable hidesBarsOnSwipe while it's refreshing.
I set INSInfiniteScrollBackgroundView's enable to NO, and shouldShowWhenDisabled is YES. when I change the scrollView's contentSize or frame, the INSInfiniteScrollBackgroundView's frame is incorrect, the INSInfiniteScrollBackgroundView's frame don't update.I change the code in observeValueForKeyPath:ofObject:change:context: to fix this bug.
Hi !
This is a very good project.
But I found some faults in use, for example,
infinite scroll
.refresh view
in the dealloc
.So ,I made some modification to your project, if you can accept these changes, please reply me, I will submit the pull request.
I'm currently having an issue where calling [self.tableView ins_beginInfinityScroll];
to trigger the initial loading is causing the infinite scroll indicator to start lower than it should be.
I've tracked this down to adjustedHeightFromScrollViewContentSize
. If I comment out the following everything works correctly:
if(self.scrollView.contentSize.height < remainingHeight) { return remainingHeight; }
What does this check provide? I noticed the issue I'm seeing is that the contentHeight is 0 (empty tableView state). When moving from an empty tableView to a non-empty, the loading using ins_beginInfinityScroll
puts the loader in the wrong initial place. I know removing the code fixes everything, but I'm not sure what the side effects will be.
please fix the following to lines in the podspec file:
s.version = '1.0.7'
s.source = { :git => 'https://github.com/inspace-io/INSPullToRefresh.git', :tag => '1.0.7'
please replace 1.0.7 to 1.0.8.
Note: you can refer to the s.version
like :tag => "v#{s.version}"
for less possible errors, then you have to only change the line of s.version
.
Any plans to support Carthage in order to be able to build your project with Carthage?
Thanks
Crashlytics says that my app sometimes crashes at deinit method, implemented as per docs say:
deinit {
tableView.ins_removeInfinityScroll()
tableView.ins_removePullToRefresh()
}
Crash log:
Thread : Crashed: com.apple.main-thread
0 MobileCatalog 488220 @objc NewsfeedViewController.deallocating_deinit (NewsfeedViewController.swift)
1 MobileCatalog 487964 @objc NewsfeedViewController.__deallocating_deinit (NewsfeedViewController.swift:26)
2 CoreFoundation 649858185 -[__NSArrayM dealloc] + 148
3 libobjc.A.dylib 946704231 objc_object::sidetable_release(bool) + 150
4 UIKit 720509339 -[UIViewController dealloc] + 1758
5 UIKit 720564553 -[UINavigationController dealloc] + 472
6 CoreFoundation 649858185 -[NSArrayM dealloc] + 148
7 libobjc.A.dylib 946704231 objc_object::sidetable_release(bool) + 150
8 UIKit 720509339 -[UIViewController dealloc] + 1758
9 UIKit 722581793 -[UITabBarController dealloc] + 640
10 UIKit 722327497 -[UIPresentationController .cxx_destruct] + 304
11 libobjc.A.dylib 946593621 object_cxxDestructFromClass(objc_object, objc_class) + 116
12 libobjc.A.dylib 946634311 objc_destructInstance + 34
13 libobjc.A.dylib 946634347 object_dispose + 14
14 UIKit 722311753 -[UIPresentationController dealloc] + 60
15 UIKit 727683289 -[_UIFullscreenPresentationController dealloc] + 60
16 libobjc.A.dylib 946704231 objc_object::sidetable_release(bool) + 150
17 UIKit 720678031 -[UIViewController _didFinishDismissTransition] + 538
18 UIKit 722297235 -[UIPresentationController transitionDidFinish:] + 466
19 UIKit 722310961 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 192
20 UIKit 720106807 -[_UIViewControllerTransitionContext completeTransition:] + 90
21 UIKit 719120821 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 540
22 UIKit 719119509 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 204
23 UIKit 719119247 -[UIViewAnimationState animationDidStop:finished:] + 78
24 QuartzCore 711342673 CA::Layer::run_animation_callbacks(void) + 252
25 libdispatch.dylib 954088407 _dispatch_client_callout + 22
26 libdispatch.dylib 954146673 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1524
27 CoreFoundation 650541421 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE* + 8
28 CoreFoundation 650534503 __CFRunLoopRun + 1574
29 CoreFoundation 649826585 CFRunLoopRunSpecific + 520
30 CoreFoundation 649826053 CFRunLoopRunInMode + 108
31 GraphicsServices 802437833 GSEventRunModal + 160
32 UIKit 719306517 UIApplicationMain + 144
33 MobileCatalog 561304 main (AppDelegate.swift:16)
34 libdyld.dylib 954390643 start + 2
Did I miss anything?
Any pointers on how to achieve infinite scrolling with a horizontally scrolling single row collection view?
During the pull refresh, I call the [self.scrollView ins_setInfinityScrollEnabled:NO];
UIScrollView contentInset is changed by stopInfiniteScrollWithStoppingContentOffset method, INSPullToRefreshBackgroundView will save the contentInset to externalContentInset. this contentInset is incorrect.
I change the stopInfiniteScrollWithStoppingContentOffset to endInfiniteScrollingWithStoppingContentOffset can resolve this problem.
As title.
Thanks.
I've tried to debug this and figure out why it is happening, but when I display my view controller, the pull-to-refresh component is displayed with extra padding above it. I am using the method ins_beginPullToRefresh()
to programmatically display the refresh view.
I've attached a screenshot of the issue:
There seems to be an issue with not-exisiting method swizzling on iOS7:
*** Assertion failure in void swizzleInstance(__unsafe_unretained id, SEL, __strong MZMethodReplacementProvider)(), ../INSPullToRefresh/INSPullToRefresh/MZMethodSwizzler.m:355
2015-12-07 10:59:57.756 myapp[1399:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid method: -[myapp.MyViewController viewWillTransitionToSize:withTransitionCoordinator:]'
In class INSPullToRefreshBackgroundView, method isScrollViewIsTableViewAndHaveSections returns YES only if the table view has at least 2 sections.
I have a table view with a single section, in that case it does not work.
when navigationBarHidden is YES, the scrollView contentInset top is 64, So I change the code in handleContentInsetDuringFrameChange: , add the navigationBarHidden judgment.
How do I enable the pull to refresh of table view is empty?
In December there was a PR merged (#89) for ios11 compatibility, do you have an ETA for a new release?
A' viewcontroller has a circle refresh , if you push to B and back to A, the A'cicle is not invisible.
My English is poor,so i want to you can get my mean!
I found that when the orientation changes, the tableView/scrollView contentInset is not properly reset, resulting in the pull to refresh view being half shown and the scrollbar inset being off.
Screenshot while idle after orientation change (Portrait -> Landscape):
Screenshot showing the scrollbar wrong inset:
I did the following to fix it on my view controller:
override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) {
let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.height
var delta : CGFloat = 0.0
if let navigationController = self.navigationController {
if navigationController.navigationBarHidden == false {
let navigationBarHeight = navigationController.navigationBar.frame.size.height
delta += navigationBarHeight
}
}
if UIApplication.sharedApplication().statusBarHidden == false {
delta += statusBarHeight
}
tableView.frame = self.view.bounds
tableView.contentInset.top = delta
tableView.scrollIndicatorInsets.top = delta
}
This should be automatically done by INSPullToRefresh, or am I wrong?
Please add ability to access activity indicator of INSDefaultInfiniteIndicator and INSDefaultPullToRefresh. I want to change it to the white style to fit dark background.
After the orientation changes the position of the RefreshControl is wrong because it doesn't adopt the new center automatically.
I fixed it for myself by adding
-(void) updateRefreshView{
[self layoutSubviews];
}
to the INSPullToRefreshBackgroundViewDelegate.
My main screen has a nav bar and tab bar. But when I push a new controller without a tab bar, the control is visible like a row on the table. Even the scroll indicator is shifted down.
I had to use this code to "fix" it. Seems to work so far.
if (!self.tabBarController) { self.tableView.contentInset = UIEdgeInsetsZero; self.tableView.scrollIndicatorInsets = UIEdgeInsetsZero; }
Could this be related to this issue #80?
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.