我正在使用像这样的基本操作来推送到 View 。
UIStoryboard *storyboard = self.navigationController.storyboard;
MenuViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"menuViewController"];
[self.navigationController pushViewController:viewController animated:YES];
一些我可以简单使用的地方:
[self.navigationController popViewControllerAnimated:YES];
但在一些地方我想弹出一个特定的 View Controller 。我尝试过的是:
UIStoryboard *storyboard = self.navigationController.storyboard;
RecordMenuViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"recordMenuViewController"];
[self.navigationController popToViewController:viewController animated:YES];
但它只是进入黑屏,就像 View 不在堆栈中一样。我在这里缺少什么?
最佳答案
如果您想使用导航堆栈弹出到特定的 View Controller ,请执行以下操作:
NSArray* vcs = self.navigationController.viewControllers;
UIViewController* target = [vcs objectAtIndex:([vcs count] - 1) - numVCsToGoBack];
[self.navigationController popToViewController:target];
关于ios - 使用 popToViewController 返回到黑屏的特定 View Controller 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31259258/