导航栏后退按钮弹出视图控制器
当点击导航控制器上的后退按钮时,视图是否会从堆栈中弹出?如果是这样,我该如何测试或确保它正确执行(换句话说,创建一个正确的导航控制器)?
我需要看看视图是否真的被弹出。有什么我可以使用 NSLog
来显示堆栈或其他内容的东西吗?
谢谢,
When hitting the Back button on a navigation controller, does the view get popped off the stack? If so, how can I test that or make sure that it does it correctly (in other words, created a proper navigation controller)?
I need to see if the view is actually getting popped. Is there anything I can NSLog
that shows me the stack or something?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,视图是从堆栈中弹出的。您可以检查堆栈的大小(视图数)来确认这一点。
Yes, the view is popped from the stack. You can check the size of the stack (number of views) to confirm this.
viewController 正在从堆栈中弹出,是的。您还可以在
- (void)viewWillAppear
和- (void)viewDidAppear
中使用NSLog(@"%@", self.navigationController.viewControllers);
如果您不相信 Apple 工程师做得很好,请查看父 viewController 的方法以查看差异。The viewController is getting popped from the stack yes. You can also
NSLog(@"%@", self.navigationController.viewControllers);
in- (void)viewWillAppear
and- (void)viewDidAppear
methods of the parent viewController to see the differences if you don't trust that Apple engineers did a good job with it.NSLog(@"%@", self.navigationController.viewControllers);
会在导航堆栈中提供 viewcontrollers 数组。您可以在视图消失之前和另一个视图出现之后对它们进行 nslogNSLog(@"%@", self.navigationController.viewControllers);
would give the viewcontrollers array in navigation stack.you can nslog them before the view disappears and after the other view appears