Giter Club home page Giter Club logo

Comments (16)

samvermette avatar samvermette commented on August 29, 2024

@danielkramer could I get my hands on that project or a simple demo project that replicates this crash? That would really help.

from svpulltorefresh.

danielkramer avatar danielkramer commented on August 29, 2024

I'll take a look. More info, dealloc on my tableviewcontroller and pulltorefresh arn't called when I pop the view off the navigation stack. If I comment out

[[self tableView] addPullToRefreshWithActionHandler:^{
[self refreshOnlineData];
[[self tableView].pullToRefreshView stopAnimating] ;
}];

My viewcontroller deallocs as expected

from svpulltorefresh.

danielkramer avatar danielkramer commented on August 29, 2024

I have a very simple testfile that shows the issue.. how should I send that to you?

from svpulltorefresh.

samvermette avatar samvermette commented on August 29, 2024

@danielkramer thanks for sending me the project but I don't seem to ever be getting the crash... should I need to run it on the device or are you getting the crash on the Simulator as well?

Shooting in the dark here, but you could try replacing

[self.scrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil];
[self.scrollView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];

with

[self addObserver:self forKeyPath:@"scrollView.contentOffset" options:NSKeyValueObservingOptionNew context:nil];
[self addObserver:self forKeyPath:@"scrollView.frame" options:NSKeyValueObservingOptionNew context:nil];

And same thing for the removeObserver calls... let me know if that fixes it.

from svpulltorefresh.

danielkramer avatar danielkramer commented on August 29, 2024

Hmm.. odd you can't get it to crash.. sometimes it takes a few times to crash. I'm running Xcode 4.4.1 and iphone simulator Version 5.1 (272.21). I'm running on the non retina iphone simulator. Run though this sequence a few times and see what happens:

Run app

Hit "Push Me"
Hit "Back"
Run "Simulate Memory Warning"

If it doesn't crash goto to the "Push Me" step and try the sequence again. After a few times it always crashes for me.

You should also notice that after you hit back you should get a "Table Dealloc!" in the Xcode console showing the tableview is unloaded.. but that doesn't happen. If you comment out binding pulltorefesh and run the test again the table is properly unloaded. So adding pulltorefresh is retaining the viewcontroller.

I tried your potential fix but didn't work for me, also the actually pull to refresh functionality broke as well

from svpulltorefresh.

samvermette avatar samvermette commented on August 29, 2024

@danielkramer the VC not getting deallocated is definitely a good lead (and tbh I'm kinda ashamed of having overlooked this). Will investigate and get back to you shortly...

from svpulltorefresh.

samvermette avatar samvermette commented on August 29, 2024

@danielkramer pushed a fix that seems to do the trick (dealloc is now getting called on the VC and I can't seem to be able to reproduce that crash anymore). Let me know!

from svpulltorefresh.

danielkramer avatar danielkramer commented on August 29, 2024

Just gave it a try. I think you've fixed the dealloc and inturn the crash I was seeing. I am seeing a couple of weird things. Here's what I'm seeing:

-load up a navigationController style app
-push a tableview onto the stack with pull to refresh, works fine
-Select a cell which in-turn pushes a new view onto the stack
-Now Go back to the previous tableview and pulltorefresh has disappeared!

Looks like when a new view is pushed over my tableview pulltorefresh is dealloc'd. I can get it to work on my end by putting "addPullToRefreshWithActionHandler" in viewWillAppear rather then viewWillLoad. So it re-binds each time that view is shown. That will work, but not sure if it's what you intended

Other interesting thing I noticed is if I put a NSLog message in the dealloc method it's always called twice. Doesn't seem to be a functional problem that I can see, but not sure.

Thanks for taking a look. As long as I can safely put it in viewWillAppear I think I'll be fine

from svpulltorefresh.

samvermette avatar samvermette commented on August 29, 2024

Not sure how to fix this one and so I'm reporting back here to get your thoughts and maybe someone else's on the issue and on possible way to fix it.

The dealloc issue was caused by the fact that the pull to refresh view increases the retain count of the table view. When the view controller goes away (and normally gets dealloced), the tableview can't be released (and therefore the view controller) because the pull to refresh view still holds references to it.

So I needed a way for SVPullToRefresh to get notified when that situation occurs. The one I found was to implement the willMoveToSuperview: in my UIScrollView category (since the tableview is moved to superview nil when removeFromSuperview is called). The problem is, when you're pushing a new view controller, the tableview also gets removed but not the view controller itself, which remains in the navigation controller stack.

What we need is a way to know whether the scroll view's view controller is attempted to get dealloced, whereas only the scroll view getting removed from the view hierarchy. Problem is, the view controller won't get dealloced as long as our tableview holds a reference to it (and so as long as our pull to refresh view hasn't been nillified). Chicken and egg problem... Any idea?

from svpulltorefresh.

danielkramer avatar danielkramer commented on August 29, 2024

I haven't had time to take a look, still a problem for me of course (and I would imagine others).. hoping it gets fixed before I release my app.. just ticking off my other issues first

from svpulltorefresh.

samvermette avatar samvermette commented on August 29, 2024

@danielkramer are you using the latest version of SVPullToRefresh? I thought I had fixed the crash with my last commit, and replaced it with the view disappearing instead...

from svpulltorefresh.

danielkramer avatar danielkramer commented on August 29, 2024

Yes, latest. Sorry I wasn't clear. The new version fixes the crash and no longer retains my tableview when I pop it off the nav stack. That's great. But I am having the new issue of it disappearing if a new view is pushed and then pop back to the tableview. I was just letting you know I'm probably no help in helping you track down this new problem.. sounds like you're looking for some advice on it

from svpulltorefresh.

yimingtang avatar yimingtang commented on August 29, 2024

The same problem.
When I push another controller into the navigation controller and go back, the pull-to-refresh view disappear.

from svpulltorefresh.

tomasikp avatar tomasikp commented on August 29, 2024

Fix in the works for this?

from svpulltorefresh.

samvermette avatar samvermette commented on August 29, 2024

This has been fixed with the big refactor I just pushed. Sorry it took so long.

from svpulltorefresh.

tomasikp avatar tomasikp commented on August 29, 2024

nice job sam

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.