iphone+在推送任何 View 时隐藏标签栏

标签 iphone ios uitabbarcontroller

我正在设计一个应用程序,它在选项卡栏中有超过4个选项,所以我想做的就是在推送任何 View 时隐藏选项卡栏,并在弹出 View 时再次显示它,我尝试了 hidesbottomwhenpushed 但没有'不为我工作。请帮忙

最佳答案

使用此功能

- (void) hideTabBar:(UITabBarController *) tabbarcontroller 
{
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.5];
        for(UIView *view in tabbarcontroller.view.subviews)
        {
            if([view isKindOfClass:[UITabBar class]])
            {
                [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
            } 
            else 
            {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
            }

        }

        [UIView commitAnimations];

 }

当你调用这个函数时

[self hideTabBar:self. tabbarcontroller];

当你想显示 tabbarcontroller 时使用这个函数

 - (void) showTabBar:(UITabBarController *) tabbarcontroller {

        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.5];
        for(UIView *view in tabbarcontroller.view.subviews)
        {
            NSLog(@"%@", view);

            if([view isKindOfClass:[UITabBar class]])
            {
                [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];

        } 
        else 
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
        }


    }

    [UIView commitAnimations]; 
}

关于iphone+在推送任何 View 时隐藏标签栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10106017/

相关文章:

iphone - 在录制的视频上添加日期和时间

ios - 核心蓝牙 - 在后台执行长期操作

iphone - 将选项卡栏 Controller 添加到 UISplitViewController 的 Root View ?

iphone - UIButton 未在自定义 UITableViewCell 内获取触摸事件

ios - 从 URL 显示 mp3 的波形

iphone - 何时在iPhone的Db中存储对象的经验法则

ios - 如何创建自定义 Realm 文件

ios - 如何在 SWIFT Xcode 中导入 Rollout.io

iphone - UINavigationController 可见 View Controller

iphone - 移除标签栏后, Storyboard 仍显示 'ghost' 标签栏项目