zoukankan      html  css  js  c++  java
  • iPhone中如何在打开一个新view时隐藏全局的TabBar?

    参考资料:http://www.cocoachina.com/bbs/simple/?t25042.html

    问题实质无非是要把View Tree里的各个组件的大小进行动态调整.

    首先在AppDelegate中我有一个UITabBarController, 比如叫 FrameViewController

    然后我要push一个叫做 UserDetails 的普通View,并且希望隐藏下面的TabBar

    使用setHidden,hidesBottomBarWhenPushed神马的终究不给力,因为即使把TabBar隐藏了,内部的ViewController所占的空间依然没有改变,因此下面会留下一片空白.

    归根结底还要自己调整尺寸.

    在AppDelegate中定义这儿一个全局函数即可

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

      然后在 UserDetail 的 viewWillAppear和viewWillDisappear中调用即可

  • 相关阅读:
    jmeter-实用插件
    python学习笔记
    TODO redis学习笔记
    查询redis数据
    【洛谷P1341】无序字母对
    【洛谷P1100】高低位交换
    【洛谷P1118】数字三角形
    【洛谷P1538】迎春舞会之数字舞蹈
    【洛谷P2947】向右看齐
    【洛谷P1351】[NOIP2014]联合权值
  • 原文地址:https://www.cnblogs.com/dabaopku/p/2264468.html
Copyright © 2011-2022 走看看