iphone - Nav Bar button loading random view before loading appropriate view -


i have button on answer view controller (a view controller displays answers) if user hits button created switches view has title of "back" , empty tableview, before switching main view of questions answered displayed. why happening? brief thing, noticeable!

 uinavigationbar *navbar = [[uinavigationbar alloc] initwithframe:cgrectmake(0, 0, [uiscreen mainscreen].bounds.size.width, 48)]; navbar.delegate = self; uinavigationitem *backitem = [[uinavigationitem alloc] initwithtitle:@"back"]; [navbar pushnavigationitem:backitem animated:no];  uinavigationitem *topitem = [[uinavigationitem alloc] initwithtitle:@"question"]; [navbar pushnavigationitem:topitem animated:no]; topitem.leftbarbuttonitem = nil;  [self.view addsubview:navbar];   - (bool)navigationbar:(uinavigationbar *)navigationbar shouldpopitem:(uinavigationitem *)item {     viewcontroller *controller = [[viewcontroller alloc] initwithnibname:@"viewcontroller" bundle:nil];    controller.modaltransitionstyle = uimodaltransitionstylefliphorizontal;    [self presentviewcontroller:controller animated:yes completion:nil];    return true; }  - (void)navigationbar:(uinavigationbar *)navigationbar didpopitem:(uinavigationitem *)item {     viewcontroller *controller = [[viewcontroller alloc] initwithnibname:@"viewcontroller" bundle:nil];    controller.modaltransitionstyle = uimodaltransitionstylefliphorizontal;    [self presentviewcontroller:controller animated:yes completion:nil]; } 

picture of view button picture of problem occurring

you're creating own uinavigationbar , uinavigationitem instances , shouldn't be. situation describe uinavigationcontroller for. when using uinavigationcontroller creates uinavigationbar , each uiviewcontroller show on screen (push navigation controller) has own uinavigationitem (with title taken title of view controller).

the reason empty 'view' titled "back" you're creating it:

uinavigationitem *backitem = [[uinavigationitem alloc] initwithtitle:@"back"]; [navbar pushnavigationitem:backitem animated:no]; 

dispense of this, create uinavigationcontroller , make question view controller it's root view controller, add navigation controller screen. when question answered, push answer view controller:

[self.navigationcontroller pushviewcontroller:answerviewcontroller animated:yes]; 

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 -