我有3個視圖控制器「根」,「父」&「孩子」。現在我正從父母的方法推進孩子。現在,當我想通過下面的代碼從子視圖彈出父:不會彈出到子視圖控制器的父視圖
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil];
Parent *svc = [storyboard instantiateViewControllerWithIdentifier:@"Parent"];
[self.navigationController popToViewController:svc animated:YES];
這顯示了錯誤:
'NSInternalInconsistencyException', reason: 'Tried to pop to a view controller that doesn't exist.'
當我寫了下面的代碼代替,它彈出一個空白屏幕! :
[self.navigationController popViewControllerAnimated:YES];
而當我寫下面的代碼,它彈出到根。 :
[self.navigationController popToRootViewControllerAnimated:YES];
但我想正好彈出到父視圖。我該怎麼做?
在此先感謝。從類父
推例如:從兒童
-(void)Custom{
if([info isEqualToString:@"message"]){
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil];
Child *cd = [storyboard instantiateViewControllerWithIdentifier:@"Child"];
[self.navigationController pushViewController:cd animated:YES];
}
}
流行例如:
-(void)viewDidLoad{
[super viewDidLoad];
[self sendMessage]
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil];
Parent *svc = [storyboard instantiateViewControllerWithIdentifier:@"Parent"];
[self.navigationController popToViewController:svc animated:YES];
}
對不起,我在這個問題寫了一些錯誤的榜樣。我編輯過。請立即檢查。 – Leo 2013-04-26 12:02:29
我的回答是有效的,但是你可以在你推送和彈出視圖控制器的地方添加代碼嗎? – danypata 2013-04-26 12:05:41
我在問題部分添加了推送和彈出代碼。請立即檢查。 – Leo 2013-04-26 12:19:14