Giter Club home page Giter Club logo

Comments (8)

guoxj avatar guoxj commented on August 29, 2024

i comment out - (void)willMoveToSuperview:(UIView *)newSuperview
and move [self startObservingScrollView]; to initWithScrollView,
and now it's working!

from svpulltorefresh.

chapados avatar chapados commented on August 29, 2024

@guoxj I committed the change that seems to have broken your code and I'm trying to understand why it's failing for you. Where are you calling the -addInfiniteScrollingWithActionHandler method? Also, do you really need to comment out -willMoveToSuperview: or does simply adding a call to [self startObservingScrollView] to initWithScrollView fix the problem? Would you be willing to dump your actionHandler block and the surrounding code into a gist. It might help figure out what's wrong.

from svpulltorefresh.

guoxj avatar guoxj commented on August 29, 2024

in loadView, i init the tableview and add the handler

  • (void)loadView
    {
    CGRect rect = APPFRAME;
    self._nearByPersonTableView = [[[UITableView alloc] initWithFrame:rect style:UITableViewStylePlain] autorelease];

    //.....
    [self._nearByPersonTableView addPullToRefreshWithActionHandler:^{
    [self refresh];
    }];

    [self._nearByPersonTableView addInfiniteScrollingWithActionHandler:^{
    [self loadMoreTaped];
    }];

    //....
    }

and i have tried to add a call to [self startObservingScrollView] to initWithScrollView,but it does't work for me.
the willMoveToSuperview got called multiple time,and finally the observer got removed.

from svpulltorefresh.

chapados avatar chapados commented on August 29, 2024

Hmm.. if you add the handlers in -loadView, then the parent view hierarchy (self.view) has not been created yet, though I'm not sure why this would prevent the handler from working. Is the issue that -[SVPullToRefresh willMoveToSuperview:] is not being called? Also, is this broken in general, or is it on a specific version of iOS? It would be helpful if you could test 2 changes independently, one to your code, and one to SVPullToRefresh:

  • Your code

Switch back to the current master of SVPullToRefresh and change your code to add the action handlers in -viewDidLoad instead of -loadView. This will ensure that the complete responder chain (including your view controller) is setup.

  • SVPullToRefresh

Change your current patch to SVPullToRefresh so that instead of commenting out -willMoveToSuperview, you just add a call to [self startObservingScrollView] to initWithScrollView:

from svpulltorefresh.

guoxj avatar guoxj commented on August 29, 2024

i have reproduced the bug in the demo code.[SVPullToRefreshDemo]

Just set the table footView in SVViewController.m in line 31:

UIButton *loadMoreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
tableView.tableFooterView = loadMoreBtn;

from svpulltorefresh.

chapados avatar chapados commented on August 29, 2024

@guoxj The reason that setting tableView.tableFooterView on line 31 causes the infiniteScrollView to disappear is because SVPullToRefresh adds itself to the tableView.tableFooterView in order to display the loading status. If you look at SVPullToRefresh.m:L194 you'll see where this is set. Right now, setting the tableFooterView after setting the infiniteScrollingActionHandler is not supported. Is this what you are doing in your original code? If so, I'm having a hard time understanding how your proposed change would solve this problem. Also, the infinite scrolling feature tracks the content offset and automatically triggers when reaching the last cell, so it's not clear to me why you would want to have 'Load More' button in the tableFooterView... That said, if you need to display a custom tableFooter, one approach would be to set tableView.tableFooterView before calling addInfiniteScrollingActionHandler:. Then in cases where you don't want to infinite scrolling, call tableView.showsInfiniteScrolling = NO, which will disable infiniteScrolling and restore your custom tableFooterView

from svpulltorefresh.

guoxj avatar guoxj commented on August 29, 2024

yes,that's the way i do in my original code.

i comment out the "- (void)willMoveToSuperview:(UIView *)newSuperview"
and move [self startObservingScrollView]; into - (id)initWithScrollView:(UIScrollView *)scrollView

and it works. in the demo code, it also works

later,i will try to change my code to fix that.

from svpulltorefresh.

samvermette avatar samvermette commented on August 29, 2024

@chapados is right that you shouldn't be showing a "load more" button if you're using the infinite scrolling feature of SVPullToRefresh. The activity indicator is nothing but a temporary transition to the additional data that is about to get appended to the table view. If no more data is available, only then you could be changing the table view's footer view (to a small dot for instance) if setting showsInfiniteScrolling to NO isn't enough.

from svpulltorefresh.

Related Issues (20)

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.