1

嘿伙计们,我想将一个新控制器推送到导航堆栈上,然后删除我从中推送的控制器。这是我的代码:

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

一切正常,但我在控制台内收到了这条消息:

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.

那么我做错了什么,如何防止我的应用程序抛出此错误消息?

4

3 回答 3

3

您可以使用 setViewController。这个例子删除所有并插入其他,但给你基本的想法:)

NSMutableArray *viewCons = [[[self navigationController]viewControllers] mutableCopy];
[viewCons removeAllObjects];
[viewCons addObject:portraitTemp];
[viewCons addObject:self];

[[self navigationController] setViewControllers:viewCons];
于 2013-02-05T09:43:06.287 回答
0

无需弹出“旧”视图控制器。navigationController 自动创建一个后退按钮。如果您从堆栈中弹出视图控制器,则没有视图控制器可以“跳”回来。这是控制台内出现消息的原因。导航控制器无法正常工作。

于 2013-02-05T09:43:17.460 回答
0
WishDetailViewController *detailView = [self.storyboard instantiateViewControllerWithIdentifier:@"WishDetailView"];
detailView.transferWishID = [NSNumber numberWithFloat:[[response objectForKey:@"id"]floatValue]];
[self.navigationController popViewControllerAnimated:NO];
[self.navigationController pushViewController:detailView animated:YES];
于 2014-01-31T07:08:29.270 回答