iOS / xcode - 如何从UITabBarController打开一个新的故事板并防止UITabBar消失?

时间:2015-05-13 23:10:16

标签: ios objective-c iphone xcode uitabbarcontroller

我一直致力于从单个UITabBarController链接多个故事板。我让它工作,我可以打开新的故事板并显示初始UIViewController,只有UITabBar在打开新故事板时消失。

以下是我用来切换到新故事板的代码:

-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
if ( [viewController isMemberOfClass:[ProfileRedirectViewController class]] )
    {
        UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Profile" bundle:nil];
        UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"ProfileTableViewController"];


        [self.view.window.rootViewController presentViewController:vc animated:YES completion:nil];
        //[self.navigationController pushViewController:vc animated:false];

        return NO;
    }
    return YES;
}

我一直在使用navigationController版本,但它什么都不做,导致死点击,日志中没有错误。我一直在寻找一个答案,也许我已经走错了路。我是xcode的新手,所以我很可能会遗漏一些明显的东西,或者使用不稳定的搜索词找到帮助。

当我们导航到主故事板中的任何其他视图时,UITabBar工作正常,只有当我移动到下一个故事板时才会丢失它。

非常感谢所有帮助!

1 个答案:

答案 0 :(得分:0)

您告诉视图窗口加载新的根,但您想要做的是让UIBarTab打开另一个故事板。看看他的帖子有一个非常好的详细答案:Proper Way to Open a New Storyboard through UITabBarController