尝试从导航堆栈中弹出视图时断言失败
我正在尝试弹出到导航堆栈中的特定视图控制器,但我做错了一些事情,因为当我尝试执行代码时弹出此错误
Assertion failure in -[UINavigationController popToViewController:transition:], /SourceCache/UIKit_Sim/UIKit-1912.3/UINavigationController.m:2229
这是导致问题的代码
FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController.xib" bundle:nil];
[self.navigationController popToViewController:firstViewController animated:YES];
I'm trying to pop to a specific view controller that is in the navigation stack but I am doing something wrong as I am getting this error pop up when I try to execute the code
Assertion failure in -[UINavigationController popToViewController:transition:], /SourceCache/UIKit_Sim/UIKit-1912.3/UINavigationController.m:2229
Here is the code thats causing the issue
FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController.xib" bundle:nil];
[self.navigationController popToViewController:firstViewController animated:YES];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设法找到一个完美运行的其他示例。
//只需选择 objectAtIndex 编号即可弹出到导航堆栈上的特定点
希望这会有所帮助。
Managed to find an example else where which works perfectly.
//Just choose objectAtIndex number to pop to a particulart point on the navigation stack
Hope this helps.
您无法弹出尚未推送的控制器实例,即使它可能与您想要返回的另一个控制器相同。
在您的代码片段中,您尝试将导航控制器的堆栈弹出到新创建的对象。该控制器不在堆栈上,因为您刚刚创建了它。由于导航控制器找不到您正在寻找的控制器,因此会抛出错误。
You cannot pop an instance of a controller that you have not pushed yet, even though it may be identical to another controller to which you would like to return.
In your code snippet, you are trying to pop the stack of the navigation controller to a newly created object. This controller is not on the stack, because you have just created it. Since the navigation controller cannot find a controller that you are looking for, it throws an error.