当用户在选项卡栏应用程序中单击返回时,如何重置 uinavigationview 以显示根控制器
当用户在选项卡栏应用程序中单击返回时,如何重置 uinavigationview 以显示根控制器
嘿,
只是想知道我会如何做到这一点。我的委托中有导航控制器以及选项卡栏控制器,每当用户单击另一个选项卡时,如果用户单击返回包含 uinavcontroller 的选项卡,我希望显示导航控制器上的根视图。
这有道理吗?
缺口
How to reset a uinavigationview to display the root controller when user clicks back to it in a tab bar app
Hey,
Just wondering how I would do this. I have the navcontroller in my delegate along with the tabbar controller and Any time the user clicks to another tab I want the rootview on the navigation controller to be shown if and when they click back the the tab that contains the uinavcontroller.
Does this make sense?
Nick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
[self.navigationController popToRootViewControllerAnimated:YES];
或者如果您不想让它动画化,则选择“否”。
这样,所有缓存的视图仍然存在,即您不会“删除/释放”根视图之上的所有视图,除非 navigationController 认为有必要。
我希望这就是您正在寻找的..
[self.navigationController popToRootViewControllerAnimated:YES];
Or NO if you don't want it to animate.
This way all the views that were cached are still there, i.e. you don't "remove/release" all the views above the root view, unless the navigationController deems it necessary.
I hope this was what You were looking for..
将代码放在appdelegate.m中
place the code in appdelegate.m
使用 UITabBar 委托方法时,必须延迟 popToRootViewControllerAnimated 调用。
When using the UITabBar delegate method, you must delay the popToRootViewControllerAnimated call.