ios - Detect navigation controller content changes but ignore hiding/showing of the navigation controller itself -


i'm uinavigationcontrollerdelegate app's main navigation controller. i'd know when view controller shown navigation controller change, , when has changed. use these delegate methods find out:

// called when navigation controller shows new top view controller via push, pop or setting of view controller stack. optional func navigationcontroller(navigationcontroller: uinavigationcontroller, willshowviewcontroller viewcontroller: uiviewcontroller, animated: bool) optional func navigationcontroller(navigationcontroller: uinavigationcontroller, didshowviewcontroller viewcontroller: uiviewcontroller, animated: bool) 

unfortunately, navigation controller contained in view controller slide-out menu. menu controller calls appearance transition methods on main view controller receives viewwilldisappear when menu shown , viewwillappear/viewdidappear when menu hidden. views contained in navigation controller rely on these events know when they're visible.

when viewwillappear fires on navigation controller itself, calls navigationcontroller:willshowviewcontroller: on me. when viewdidappear fires on navigation controller, calls navigationcontroller:didshowviewcontroller:.

is there way can distinguish between navigation controller presenting different content view controller , navigation controller being shown?

i think can accomplish subclassing navigation controller, , adding bool property set in viewwillappear,

-(void)viewwillappear:(bool)animated {     [super viewwillappear:animated];     self.willbeappearing = yes; } 

in delegate, check property, , set no in didshowviewcontroller: method, if it's yes,

-(void)navigationcontroller:(rdnavcontroller *)navigationcontroller willshowviewcontroller:(uiviewcontroller *)viewcontroller animated:(bool)animated {     if (navigationcontroller.willbeappearing == no) {         nslog(@"the controller changing");         // need when new controller appear     } }   -(void)navigationcontroller:(rdnavcontroller *)navigationcontroller didshowviewcontroller:(uiviewcontroller *)viewcontroller animated:(bool)animated {     if (navigationcontroller.willbeappearing == no) {         nslog(@"the controller has changed");         // need when new controller has appeared     }else{         navigationcontroller.willbeappearing = no;     } } 

notice changed class of passed in navigation controller in delegate methods custom class.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -