ios - Pushing a new VC into the navigationController seems to have no effect -


this problem sounds quite basic don’t understand overlooking.

i trying push new view controller navigation controller, topviewcontroller remains unaffected.

#import "tnpviewcontroller.h" @interface tncviewcontroller : uiviewcontroller <uicollectionviewdatasource, uicollectionviewdelegateflowlayout>  @implementation tncviewcontroller  -(void)userdidselectnewsnotification:(nsnotification*)note  {      tnpviewcontroller *nextviewcontroller = [[tnpviewcontroller alloc] init];      [[self navigationcontroller] pushviewcontroller:nextviewcontroller animated:yes];      uiviewcontroller *test = [[self navigationcontroller] topviewcontroller];  } 

the test shows instance of tncviewcontroller instead of tnpviewcontroller. how possible?

update

thanks everyone's participation. method name indicating notifications red herring. found problem, stuart had mentioned deleted later on. (as have high reputation score, still can see deleted post).

my initial unit test this:

-(void)testselectingnewspushesnewviewcontroller {     [viewcontroller userdidselectnewsnotification:nil];     uiviewcontroller *currenttopvc = navcontroller.topviewcontroller;     xctassertfalse([currenttopvc isequal:viewcontroller], @"new viewcontroller should pushed onto stack.");     xctasserttrue([currenttopvc iskindofclass:[tnpviewcontroller class]], @"new vc should tnpviewcontroller"); } 

and failed. set breakpoint , tried test instance above , still showing wrong topviewcontroller.

at least unit test works if change

[[self navigationcontroller] pushviewcontroller:nextviewcontroller animated:yes]; 

to

[[self navigationcontroller] pushviewcontroller:nextviewcontroller animated:no]; 

a better solution use animated constant unit tests disable animations.

this doesn't answer question why navigationcontroller not pushing vc. suggestion possible approach.

you instead add new vc on storyboard , activate segue when userdidselectnewsnotification method activated. change information accordingly event in vc, specially since initializing every time anyway.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -