Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JASidePanels delegates for viewWillAppear ext not getting called

So I have set up JASidePanels with a root controller which implements JASidePanelController and my left panel which is a different UIViewController.

My problem is the left panel only receives the viewWillAppear viewDidAppear/disappear and viewWillAppear and viewDid/WillLoad only once for the first time the user slides the centre panel away. From then on these callback functions do not get called again.

What is the best way or how should I respond to these events inside my left panel view controller.

like image 260
Vlad Avatar asked Jun 20 '14 08:06

Vlad


1 Answers

Ok I figured it out.

There is a property called

@property (nonatomic, readonly) JASidePanelState state;

It states: "Current state of panels. Use KVO to monitor state changes"

There are 3 states changes I can monitor with this:

JASidePanelCenterVisible = 1,
JASidePanelLeftVisible,
JASidePanelRightVisible

I now react to KVO changes to the state. In my left panel's viewDidLoad I have:

[self.sidePanelController addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:nil];

and to receive the change on state I have:

- (void)observeValueForKeyPath:(NSString *)keyPath
                      ofObject:(id)object
                        change:(NSDictionary *)change
                       context:(void *)context
{
    if ([keyPath isEqual:@"state"]) {
        if ([change[@"new"] isEqual:[NSNumber numberWithInt:1]]) {
            NSLog(@"Saving settings");
        }
    }
}
like image 111
Vlad Avatar answered Oct 16 '22 17:10

Vlad