Reputation: 5321
Hey Guys i want to push a new controller onto the navigation stack and then remove the controller where i pushed from. Here is my Code :
WishDetailViewController *detailView = [self.storyboard instantiateViewControllerWithIdentifier:@"WishDetailView"];
detailView.transferWishID = [NSNumber numberWithFloat:[[response objectForKey:@"id"]floatValue]];
[self.navigationController pushViewController:detailView animated:YES];
[self.navigationController popViewControllerAnimated:NO];
Everthing works fine, but i got this message here inside the console :
2013-02-05 10:32:42.029 BWMApp[1444:1a603] nested pop animation can result in corrupted navigation bar
2013-02-05 10:32:42.392 BWMApp[1444:1a603] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
So what i am doing wrong and how can i prevent my app from throwing this error message ?
Upvotes: 1
Views: 1163
Reputation: 101
WishDetailViewController *detailView = [self.storyboard instantiateViewControllerWithIdentifier:@"WishDetailView"];
detailView.transferWishID = [NSNumber numberWithFloat:[[response objectForKey:@"id"]floatValue]];
[self.navigationController popViewControllerAnimated:NO];
[self.navigationController pushViewController:detailView animated:YES];
Upvotes: 0
Reputation: 406
There is no need to pop the "old" viewcontroller. The navigationController create a backbutton automatically. if you pop the viewcontoller from the stack there is no viewcontroller to "jump" back. This is the cause of message inside the console. The navigationController can't work correctly.
Upvotes: 0
Reputation: 362
You can use setViewController. This example removes all and insert others, but give you the basic idea :)
NSMutableArray *viewCons = [[[self navigationController]viewControllers] mutableCopy];
[viewCons removeAllObjects];
[viewCons addObject:portraitTemp];
[viewCons addObject:self];
[[self navigationController] setViewControllers:viewCons];
Upvotes: 3