my project complex (a bit probably) question simple, here's code
... self.vc = [[classname alloc] init]; if ([[self.navigationcontroller.viewcontrollers lastobject] iskindofclass:[classname class]]) { [self backandgo:self.vc title:@"title"]; } else { [self vai:self.vc title:@"title"]; } ...
in code i've go directly in next view if current view different classname
, otherwise go of 1 view , go next.
- (void)backandgo:(id)view title:(nsstring *)title
- (void)backandgo:(id)view title:(nsstring *)title { nslog(@"before %@,%d",[self.navigationcontroller viewcontrollers],[[self.navigationcontroller viewcontrollers] count]); [self.navigationcontroller popviewcontrolleranimated:no]; alcparentviewcontroller *viewcontroller = (alcparentviewcontroller *)view; [self.navigationcontroller pushviewcontroller:viewcontroller animated:yes]; nslog(@"after %@,%d",[self.navigationcontroller viewcontrollers],[[self.navigationcontroller viewcontrollers] count]); }
alcparentviewcontroller parent class of vc, in method first log of navigatin controller correct stack of viewcontrollers, , popviewcontroller
executed in second log navigationcontroller null 0 element obviously, , pushviewcontroller
method not executed, why? ideas?
- (void)vai:(id)view title:(nsstring *)title
- (void)vai:(id)view title:(nsstring *)title { alcparentviewcontroller *viewcontroller = (alcparentviewcontroller *)view; [self.navigationcontroller pushviewcontroller:viewcontroller animated:yes]; }
this instead other method reach directly second view, , works correctly, courius thing (almost me) dispite nil pushviewcontroller, navigation (push , pop) in other view works correctly...
edit 1:
as lucaslt89 said i've put breakpoint in second log , make "po self.navigationcontroller" in consolle, here result
(lldb) po self.navigationcontroller $0 = 0x00000000 <nil> (lldb)
it's nil, can see in log without breakpoint...
edit 2:
(lldb) po self.navigationcontroller $0 = 0x099787d0 <uinavigationcontroller: 0x99787d0> (lldb) po auxnavcontroller $1 = 0x099787d0 <uinavigationcontroller: 0x99787d0> (lldb)
after operations suggested lucaslt89, 2 address same
according last edit, 1 solution hold reference navigation controller. backandgo method should that
- (void)backandgo:(id)view title:(nsstring *)title { nslog(@"before %@,%d",[self.navigationcontroller viewcontrollers],[[self.navigationcontroller viewcontrollers] count]); uinavigationcontroller *auxnavcontroller = self.navigationcontroller; [self.navigationcontroller popviewcontrolleranimated:no]; alcparentviewcontroller *viewcontroller = (alcparentviewcontroller *)view; [auxnavcontroller pushviewcontroller:viewcontroller animated:yes]; nslog(@"after %@,%d",[auxnavcontroller viewcontrollers],[[auxnavcontroller viewcontrollers] count]); }
if debug that, address of self.navigationcontroller prior pop should same auxnavcontroller after pop. try , tell results!
Comments
Post a Comment