PopToRootViewController 达到第 3 级,栏按钮项目没有弹出
我用 UINavigationController 推送到一些视图控制器,当我在第三个 UISubViewController 上时,我编码为“popToRootViewController”,它弹出回来,但是导航栏项目推送到第二个视图控制器没有到第一个..
- 我尝试了带动画和不带动画的方法,但什么都不会改变。
- 我试图说 self.navigationController.navigationBar 弹出回来,但它对我的栏没有任何作用。
谢谢你的帮助..
I'm pushing to a few viewcontrollers with my UINavigationController and when I'm on my 3rd UISubViewController I coded to 'popToRootViewController' and it pop's back, but the navigationbar-items push to the 2nd view controller not to the 1st..
- I tried it with and without animating, but nothing is gonna change.
- I tried to say self.navigationController.navigationBar pop back, but it do nothing on my bar.
Thanks for help..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我对你的问题有点困惑,但我认为这应该有帮助。据我所知,UINavigationController 上的“后退”按钮不能返回超过 1 次。所以你要做的就是添加另一个执行 popToRootViewController 功能的按钮。尝试这样的操作:
这将在导航控制器的右侧添加一个按钮。下一步是添加一个名为您在操作中命名的函数(在本例中它需要称为“homeAction”)。看起来像这样:
这应该覆盖弹出回控制器根目录(无论您在堆栈中)。您还必须对 .h 文件使用 IBAction 方法,但除此之外,它应该执行您想要执行的所有操作。
I am a little confused at your question but I think this should help. As far as I know you can't have the "back" button on a UINavigationController go back more than 1 pop. So what you do is you have to add another button that does the popToRootViewController function. Try something like this:
This will add a button to the right on your navigation controller. The next step is to add a function called whatever you name in the action (in this case it needs to be called "homeAction"). This looks like so:
This should cover the pop back to the root of the controller where ever you are in the stack. You will also have to IBAction method to your .h file but other than that it should do everything you want to.
除非你对 NavigationController 的 UIViewControllers 数组做了一些奇怪的事情,否则该方法应该是:
unless you are doing something odd with the array of UIViewControllers of NavigationController, the method should be: