从窗口层次结构中删除导航或选项卡栏控制器 [英] Remove navigation or tab bar controller from window hierarchy

查看:49
本文介绍了从窗口层次结构中删除导航或选项卡栏控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些时候,我需要一个tabBar控制器而不是一个导航控制器.为此,我释放了导航控制器,并在窗口中添加了标签栏.

At some point I need a tabBar controller instead of a navigation controller. To achieve this I have released the navigation controller and added a tab bar to the window.

UINavigationcontroller是否已从窗口层次结构中删除?

Is the UINavigationcontroller removed from the window hierarchy?

推荐答案

我了解您想从导航控制器切换到TabBar控制器,然后再返回,但是您担心一旦删除,您将无法拿回来.

I understand that you want to switch from the navitation controller to a TabBar controller and back, but you are concerned that once removed, you won't be able to get it back.

显而易见的解决方案不是删除它们,而是隐藏它们.以下是TabBar控制器的示例,它仅将y点的动画从431设置为480,以使其不可见并返回.

The obvious solution is not to remove them, but to hide them. The following is a sample for the TabBar controller, it simply animates the y point from 431 to 480 so it gets out of view and back.

- (void) hidetabbar:(BOOL)hiddenTabBar {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    for(UIView *view in self.uiTabBarController.view.subviews){
        if([view isKindOfClass:[UITabBar class]]) {
            if (hiddenTabBar) {
                [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
            }
        } else {
            if (hiddenTabBar) {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
            }
        }
    }
    [UIView commitAnimations];  
}

您可以对导航控制器执行完全相同的操作.

You can do exactly the same for the navigation controller.

这篇关于从窗口层次结构中删除导航或选项卡栏控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆