推送一个新的ViewController并从NavigationStack弹出最后一个

时间:2013-02-05 09:36:44

标签: ios cocoa-touch uinavigationcontroller

嘿伙计们我想把一个新的控制器推到导航堆栈上然后移除我推动的控制器。 这是我的代码:

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工作正常,但我在控制台内收到了这条消息:

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.

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

3 个答案:

答案 0 :(得分:3)

您可以使用setViewController。此示例删除所有并插入其他示例,但为您提供基本想法:)

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

[[self navigationController] setViewControllers:viewCons];

答案 1 :(得分:0)

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

答案 2 :(得分: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];