GithubHelp home page GithubHelp logo

m1entus / inspulltorefresh Goto Github PK

View Code? Open in Web Editor NEW
815.0 815.0 82.0 843 KB

A simple to use very generic pull-to-refresh and infinite scrolling functionalities as a UIScrollView category.

License: MIT License

Objective-C 99.42% Ruby 0.58%

inspulltorefresh's People

Contributors

cerupcat avatar coybit avatar hzx157 avatar imaks avatar luosheng avatar m1entus avatar mjgaylord avatar pridechung avatar zmzhuai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inspulltorefresh's Issues

The circle animation is not invisible

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!

iPad layout issue

When I use library with iPad device and type of INSLabelPullToRefresh, layout not fits in landscape mode.

screen shot 2016-02-26 at 15 52 20

Table view with sections not properly detected

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.

UIScrollView contentInset maybe not correct during the pull refresh

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.

Configurable activity Indicator style

Please add ability to access activity indicator of INSDefaultInfiniteIndicator and INSDefaultPullToRefresh. I want to change it to the white style to fit dark background.

Pushing a View Controller Messes Up the contentOffset

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.

load more

can you plz add load more for both table and collerciton view

Control not hidden when new controller is presented without tab bar

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?

Wrong center after orientation change

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.

when navigationviewcontroller pop,error happened.

AController ->push ->BController(INSPullToRefresh)

when BController poped, error happened.

error log
..UICollectionView was deallocated while key value observers were still registered with it...

Can you explain adjustedHeightFromScrollViewContentSize?

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.

The praise from coramo

Hi !

This is a very good project.

But I found some faults in use, for example,

  • It will be hidden view after in the disable infinite scroll.
  • need to delete the 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.

https://github.com/coramo/INSPullToRefresh/tree/acfun

activity indicator doesn't back to its position

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.

Orientation change problem (insets are off)

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 while idle after orientation change (Portrait -> Landscape)

Screenshot showing the scrollbar wrong inset:
Screenshot of the scrollbar with 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?

UITableView contentOffset(ContentInset?) maybe not correct after automatic fresh when app launch

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:

  1. Launch app and first automatically call tableView.ins_beginPullToRefresh() method, when this behavior appears, scroll this tableView to normal state(eliminate the padding) manually, and then pull to refresh again manually, no padding exists here. If we do not scroll the tableView to normal state manually and pull to refresh manually again, this padding will also exist after finishing refresh. That is to say, this behavior may only appears first tableView.ins_beginPullToRefresh() automatic call.
  2. Debug the app and insert output statement to endRefreshing method in INSPullToRefreshBackgroundView.m as NSLog(@"scrollView contentInset top: %f", self.scrollView.contentInset.top), when this behavior appears, the output in console is "scrollView contentInset top: 150.000000"(I initialize the pullToRefreshBackgroundView's Height as 150.0), and when this behavior does not appear, the output is “scrollView contentInset top: 0.0000000”.
  3. When add statement [self.scrollView setContentInset: UIEdgeInsetsZeror]; before dispatch_async(dispatch_get_main_queue(), ^{[self.scrollView setContentOffset: originalContentOffset animated: NO];}); in endRefreshing method in INSPullToRefreshBackgroundView.m file, debug the app and this behavoir will disappear. (I don't know whether it is reasonable to do as this)
  4. When add output statement NSLog(@"loadingInset.top = %f", self.externalContentInset.top); (below UIEdgeInsets loadingInset = self.externalContentInset; statement) to scrollViewDidScroll:(CGPoint)contentOffset method in INSPullToRefreshBackgroundView.m file, debug the app, when this behavior appears, the console window will output "loadingInset.top = 0.000000" for about 3 or 4 times, and then output "loadingInset.top = 150.000000" for about more than 10 times; when this behavior does not appear, the console windown will output "loadingInset.top = 0.000000" only once. So this scrollViewDidScroll:method will be called dozens of times when this weird behavior occurs.
  5. This behavior appears more frequently in real iPhone than simulators.

Please check the contentOffset or contentInset when finish pull to refresh, and this weird behavior, thanks!

INSInfiniteScrollBackgroundView's frame may incorrect.

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.

Crash on iOS7

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:]'

When doing ins_endPullToRefresh, CollectionView Item behavior is strange.

movie

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)

UICollectionView

Awfull gap at the top of the CollectionView It does work correctly on the tableview.
screen shot 2015-12-08 at 6 25 23 pm

Carthage support

Any plans to support Carthage in order to be able to build your project with Carthage?

Thanks

Bad behaviour when leaving and returning to view controller while loading

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.

ios simulator screen shot 14 jul 2015 10 17 19
ios simulator screen shot 14 jul 2015 10 17 27

ETA for new release

In December there was a PR merged (#89) for ios11 compatibility, do you have an ETA for a new release?

Scrolling while loading with section headers leaves a gap

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:

screen shot 2015-02-25 at 3 01 12 pm

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:

screen shot 2015-02-25 at 3 01 25 pm

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.

Crash at deinit

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?

Invisible pull-to-refresh when slowly refreshing.

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.

Offset changes when Navigation Bar appears/disappears while refreshing

Here's how to reproduce:

  1. Enable hidesBarsOnSwipe on navigation controller
  2. Pull to refresh
  3. While refreshing, swipe scroll view to make navbar appear/disappear
  4. After refresh is done, the refresh view will not return to it's original position

Repeating these steps will make it go lower and lower.

A quick solution for me was to disable hidesBarsOnSwipe while it's refreshing.

podspec is not updated to use tag 1.0.8

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.

Issue when starting and ending refresh in the same call sequence

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.