ios - UINavigationController subclass not calling willShowViewController when expected -


i have implemented application slide in styled menu using ecslidingviewcontroller

at present have following setup: initial view controller subclass of ecslidingviewcontroller. handles pushing of top view controller (the main view displayed on screen) , underleftcontroller menu.

the menu tableview controller subclass when row clicked new top view controller pushed onto stack.

per previous question use navigation controller (subclassed) holds single root view controller. each time row selected new instance of navigation controller loaded different view controller, old dealloc'd. example:

// check if settings view displayed if reset top view else load topviewcontroller.                 uinavigationcontroller *navcontroller = (uinavigationcontroller *)self.slidingviewcontroller.topviewcontroller;                 uiviewcontroller *vc = navcontroller.topviewcontroller;                 if ([vc iskindofclass:[messettingsviewcontroller class]]) {                     [self.slidingviewcontroller resettopview];                 } else {                     mesmainnavviewcontroller *mainnavcontroller = [[mesmainnavviewcontroller alloc] initwithrootviewcontroller:[self.storyboard instantiateviewcontrollerwithidentifier:@"settingsvc"]];                      __weak typeof(self) weakself = self;                      [self.slidingviewcontroller anchortopviewoffscreento:ecright animations:nil oncomplete:^{                         cgrect frame = self.slidingviewcontroller.topviewcontroller.view.frame;                         self.slidingviewcontroller.topviewcontroller = mainnavcontroller;                         self.slidingviewcontroller.topviewcontroller.view.frame = frame;                         [weakself.slidingviewcontroller resettopviewwithanimations:nil oncomplete:^{                             [weakself updatecurrentcell];                         }];                     }];                 } 

this working fine @ moment. issue have login sequence. if user logs out different navigation stack pushed on modally. once user completes successful login notification made. received initial view controller (from above):

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(didloginuser) name:@"logincompletenotification" object:nil]; 

the method handles pushing user new instance of subclassed navigation controller in question, home controller root.

// if view controller not home send them home uinavigationcontroller *navcontroller = (uinavigationcontroller *)self.topviewcontroller; uiviewcontroller *vc = navcontroller.topviewcontroller; if (![vc iskindofclass:[meshomeviewcontroller class]]) {     uistoryboard *storyboard;      if (ui_user_interface_idiom() == uiuserinterfaceidiomphone) {         storyboard = [uistoryboard storyboardwithname:@"mainstoryboard_iphone" bundle:nil];     } else if (ui_user_interface_idiom() == uiuserinterfaceidiompad) {         storyboard = [uistoryboard storyboardwithname:@"mainstoryboard_ipad" bundle:nil];     }      mesmainnavviewcontroller *mainnavcontroller = [[mesmainnavviewcontroller alloc] initwithrootviewcontroller:[self.storyboard instantiateviewcontrollerwithidentifier:@"homevc"]];      self.topviewcontroller = mainnavcontroller;     [self resettopview];  } 

the problem appears following part:

mesmainnavviewcontroller *mainnavcontroller = [[mesmainnavviewcontroller alloc] initwithrootviewcontroller:[self.storyboard instantiateviewcontrollerwithidentifier:@"homevc"]];  self.topviewcontroller = mainnavcontroller; 

when new instance of navigation controller created delegate method willshowviewcontroller not appear called? cannot find out why, calls when controller changed via menu table view , uses same method create, thoughts?

the apple docs states that

the uinavigationcontrollerdelegate protocol defines methods navigation controller delegate can implement change behavior when view controllers pushed , popped stack of navigation controller.

so, think method willshowviewcontroller called if push or pop view controller to/from navigation stack.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -