2013-02-05 64 views
1

嘿,夥計們我想把一個新的控制器推到導航棧上,然後移除我從哪裏推出的控制器。 這裏是我的代碼:推一個新的ViewController並從NavigationStack彈出最後一個

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. 

所以我做錯了,我怎麼能阻止我的應用程序從引發此錯誤信息 ?

+0

你試過先彈出當前最頂層的視圖控制器,然後推新的?或者,你可以使用'-setViewControllers:animated:'。 –

回答

3

您可以使用setViewController。本示例刪除所有和插入別人,而是給你的基本思路:)

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

[[self navigationController] setViewControllers:viewCons]; 
0

沒有必要彈出的「老」視圖 - 控制。 navigationController自動創建一個後退按鈕。如果您從堆棧中彈出viewcontoller,則不會有viewcontroller「跳回」。這是控制檯內部消息的原因。 navigationController無法正常工作。

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]; 
相關問題