Push a new ViewController and Pop the last one from NavigationStack

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 ?

Answers


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];

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.


WishDetailViewController *detailView = [self.storyboard instantiateViewControllerWithIdentifier:@"WishDetailView"];
detailView.transferWishID = [NSNumber numberWithFloat:[[response objectForKey:@"id"]floatValue]];
[self.navigationController popViewControllerAnimated:NO];
[self.navigationController pushViewController:detailView animated:YES];

Need Your Help

WPF DataGrid Validation error not being caught

wpf validation datagrid

I am trying to use exception validation on a cell in a DataGrid together with a style on the DataGridTextColumn's EditingElementStyle to set a tooltip with the content of the error. The error occur...