JASidePanels delegates for viewWillAppear ext not getting a call

So, I created JASidePanels with a root controller that implements JASidePanelController and my left pane, which is another UIViewController.

My problem is that the left panel only gets viewWillAppear viewDidAppear / disappears, and viewWillAppear and viewDid / WillLoad only once when the user removes the center panel. Since then, these callback functions have not been called again.

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

+6
source share
1 answer

Ok, I figured it out.

There is a property called

@property (nonatomic, readonly) JASidePanelState state; 

It says: "The current state of the panels. Use KVO to monitor state changes."

There are 3 state changes that I can control with this:

 JASidePanelCenterVisible = 1, JASidePanelLeftVisible, JASidePanelRightVisible 

Now I react to changes in the KVO to the state. In the left pane of viewDidLoad I have:

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

and to get a change in 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"); } } } 
+12
source

Source: https://habr.com/ru/post/971090/


All Articles