iOS 5 选项卡视图更改为推送根控制器(故事板)
我有一个 uitabbarcontroller,它有 3 个项目。每个项目都有自己的导航控制器。 例如,在选项卡 1 中,用户导航到其他子视图,然后更改为选项卡 2,然后返回选项卡 1。选项卡 1 显示子视图。我如何推送根视图控制器而不是子视图? 我的 uitabbarcontroller 是定制的,并且具有:
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
它是执行某种pushrootviewcontroller 的正确位置吗? 如何获得控制器?
编辑:
我已实现以下内容
UITabBarController<UITabBarControllerDelegate, UITabBarDelegate>
,并且
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if (tabBarController.selectedIndex == 0)
{
NSLog(@"test%@",@"test");
[self.tabBarController.selectedViewController.navigationController popToRootViewControllerAnimated:NO];
}
}
可以在调试器中看到 nslog 输出,但 popto root 不起作用。有什么想法吗?
i have a uitabbarcontroller which has 3 items. each item has its own navigation controller.
for example in tab 1 the user navigates to other subview and then changes to tab 2 and then back to the tab 1. the tab one shows the subview. how can i push the root view controller instead of the subview?
my uitabbarcontroller is customized and has:
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
is it the right place to do some kind of pushrootviewcontroller?
how to get the controller?
edit:
i have the following implemented
UITabBarController<UITabBarControllerDelegate, UITabBarDelegate>
and
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if (tabBarController.selectedIndex == 0)
{
NSLog(@"test%@",@"test");
[self.tabBarController.selectedViewController.navigationController popToRootViewControllerAnimated:NO];
}
}
nslog output can be seen in the debugger but popto root doesnt work. any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,代码应该如下所示。现在它按照我想要的方式工作了。
ok the code should look like this. and now it works the way i wanted.