AAPullToRefresh icon indicating copy to clipboard operation
AAPullToRefresh copied to clipboard

Memory / deallocated error in NavigationController

Open trainerleipzig opened this issue 11 years ago • 6 comments

I have a navigation controller based application. At the first view there exist a button who push another ViewController or TableViewController to the navigation controller stack. This ViewController / TableViewController use the AAPullToRefresh. If I go back to the main root controller, I get the follow error message:

"An instance 0x99fca00 of class UITableView was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: <NSKeyValueObservationInfo 0x8ba4790> ( <NSKeyValueObservance 0x8bcffe0: Observer: 0x8bcc2d0, Key path: contentOffset, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x8cd3d80> <NSKeyValueObservance 0x8bd0040: Observer: 0x8bcc2d0, Key path: contentSize, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x8cd5970> <NSKeyValueObservance 0x8bd00e0: Observer: 0x8bcc2d0, Key path: frame, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x8cd5fc0> )"

If I need a ViewController with ScrollView it's the same. Only the word "UITableView" replaced by "UIScrollView". The message replicate with every new push of the controller. What can I do?

trainerleipzig avatar Jan 09 '14 20:01 trainerleipzig

add this method to AAPullToRefresh.m

-(void) dealloc
{
    @try
    {
        [self.scrollView removeObserver:self forKeyPath:@"contentOffset"];
        [self.scrollView removeObserver:self forKeyPath:@"contentSize"];
        [self.scrollView removeObserver:self forKeyPath:@"frame"];
    }
    @catch (NSException *exception)
    { 
    }
}

arielpollack avatar Jul 29 '14 11:07 arielpollack

Adding -(void) dealloc {..} did not help me with this issue. After I switched @property (nonatomic, weak) UIScrollView *scrollView; to strong in AAPullToRefresh.h error is gone.

xzenon avatar Sep 18 '14 23:09 xzenon

Probably same issue #8.

r-plus avatar Nov 23 '14 14:11 r-plus

@xzenon : can you tell me why ? :+1:

zeuspnt avatar Aug 06 '15 08:08 zeuspnt

You don't have to add - (void)dealloc to AAPullToRefresh.m, just add:

- (void)dealloc {
    pullToRefresh.showPullToRefresh = NO;
}

to your ViewController. it's work for me.

meilbn avatar Feb 26 '16 11:02 meilbn

@arielpollack Thanks for your answer man. I was stuck with the same issue for past 3 days.

sbmsingh avatar Apr 22 '16 09:04 sbmsingh