ios - Navigation Stack is nil after setViewControllers -
here hierarchy:
a - b - c - d (tabs) | | | | | | | | ----------------> addeventviewcontroller (can called tabs) | | |----> suggestfeedcontroller (can accessed b only) let's imagine i'm in d tab, , call addeventviewcontroller. after this, want redirect user "suggestfeedcontroller", want keep hierarchy, means pressing button should redirect b , not addeventviewcontroller nor d.
what have tried following:
uitabbarcontroller *tabbarcontroller = ((uitabbarcontroller *)appdelegate.window.rootviewcontroller); [tabbarcontroller setselectedindex:1]; // selecting b tab uistoryboard* storyboard= appdelegate.window.rootviewcontroller.storyboard; uicategoryfeedcontroller *cfvc = [storyboard instantiateviewcontrollerwithidentifier:@"uicategoryfeedcontroller"]; // instantiating b view controller suggestfeed *suggestfeed = [storyboard instantiateviewcontrollerwithidentifier:@"suggestfeed"]; nsarray *viewcontrollers = [[nsarray alloc] initwithobjects:cfvc, suggestfeed, nil]; // trying create own navigation stack, b first, suggest feed [self.navigationcontroller pushviewcontroller:suggestfeed animated:no]; // guys on internet push, if don't think it's necessary because it's in stack nslog(@"nav stack1 : %@", self.navigationcontroller.viewcontrollers ); /* returns stack1 : ( "<d: 0xa627990>", "<addeventviewcontroller: 0x108cb7e0>", "<suggestfeed: 0x123735f0>" ) */ [self.navigationcontroller setviewcontrollers:viewcontrollers animated:no]; nslog(@"nav stack2 : %@", self.navigationcontroller.viewcontrollers ); /* returns stack2 : (null) */ am doing wrong? (stupid question)
why stack2 nil, while have set viewcontrollers array?
if can bring help, in advance :-)
have checked cfvc not nil? case if @"uicategoryfeedcontroller" doesn't match identifier in storyboard. ask because make viewcontrollers empty array, explain results of logging.
on note, i'm guessing have set-up each tab in uitabbarcontroller contains own navigation stack (i.e. there 4 uinavigationcontroller instances, set viewcontrollers of tab bar controller). secondly, assume self in example view controller d. means whenever call self.navigationcontroller in method, navigation controller in tab d, regardless of tab selected. set view controllers in tab b, have reference navigation controller in tab b. if i'm correct assumptions, like:
uinavigationcontroller *tabbnavigationcontroller = tabbarcontroller.viewcontrollers[1]; setting viewcontrollers array on this navigation controller should trick. also, you're right, don't want pushviewcontroller bit.
Comments
Post a Comment