按下按钮以允许全屏查看内容时是否可以隐藏选项卡栏?

发布于 2024-07-29 22:43:20 字数 604 浏览 7 评论 0原文

我的基于导航的应用程序的详细视图中有一个 UITabBar。 我将文本和图像存储在表格视图中,并希望用户能够点击单元格来隐藏导航控制器和选项卡栏,以便全屏查看内容。

我找到了隐藏顶部栏的代码,但隐藏选项卡栏似乎并不容易。

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
 [self.navigationController setNavigationBarHidden:YES animated:YES];

有谁知道如何做到这一点?

一旦视图已经加载,此代码就无法隐藏 tabBar。

  yourTabViewController.hidesBottomBarWhenPushed = YES;

这是我找到的代码。 似乎只有在加载视图时才起作用,因此一旦标签栏已经出现,它就不能用于隐藏标签栏。 我仍在努力完成这项工作。 请帮忙!!!

    self.tabBarController.tabBar.hidden = YES;

I have a UITabBar in the detail view of my navigation based application. I am storing text and images in a tableview and would like the user to be able to tap on a cell to hide the navigation controller and the tabbar for full screen viewing of the content.

I found this code for hiding the top bars, but it does not seem as easy to hide the tabbar.

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
 [self.navigationController setNavigationBarHidden:YES animated:YES];

Does anyone know how to do this?

This code does not work to hide the tabBar once the view is already loaded.

  yourTabViewController.hidesBottomBarWhenPushed = YES;

This is the code I found. Seems to only work when the view is loaded though, so it can't be used to hide the tabbar once it has already appeared. I'm still struggling to make this work. Please help!!!

    self.tabBarController.tabBar.hidden = YES;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

腻橙味 2024-08-05 22:43:20

有一种内置方法可以执行此操作:

self.hidesBottomBarWhenPushed = YES;

但是您必须在推送视图之前执行此操作。 这就是您可能想要使用它的方式:

ChildViewController* childVC = [[ChildViewController alloc] init];
childVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:childVC animated:YES];
[childVC release];

There's a built-in way to do this:

self.hidesBottomBarWhenPushed = YES;

But you have to do this BEFORE the view is pushed. This is how you might want to use that:

ChildViewController* childVC = [[ChildViewController alloc] init];
childVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:childVC animated:YES];
[childVC release];
与他有关 2024-08-05 22:43:20

我发现的最好的解决方法是更改​​视图大小,使其覆盖选项卡栏。 这是我在选择一行时隐藏 statusBar、navBar 和 tabBar 的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

if (appDelegate.navigationController.navigationBar.hidden == NO)
{
    [[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
    [appDelegate.navigationController setNavigationBarHidden:YES animated:YES];

    [UIView beginAnimations:@"HideTabbar" context:nil];
    [UIView setAnimationDuration:.2];
    self.view.frame = CGRectMake(0,0,320,480);
    [UIView commitAnimations];
}
if (appDelegate.navigationController.navigationBar.hidden == YES)
{
    [[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
    [appDelegate.navigationController setNavigationBarHidden:NO animated:YES];

    [UIView beginAnimations:@"ShowTabbar" context:nil];
    [UIView setAnimationDuration:.2];
    self.view.frame = CGRectMake(0,0,320,368);
    [UIView commitAnimations];
}   
}

The best workaround I have found is to change the view size so that it covers the tabbar. Here's my code for hiding the statusBar, navBar, and tabBar when a row is selected:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

if (appDelegate.navigationController.navigationBar.hidden == NO)
{
    [[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
    [appDelegate.navigationController setNavigationBarHidden:YES animated:YES];

    [UIView beginAnimations:@"HideTabbar" context:nil];
    [UIView setAnimationDuration:.2];
    self.view.frame = CGRectMake(0,0,320,480);
    [UIView commitAnimations];
}
if (appDelegate.navigationController.navigationBar.hidden == YES)
{
    [[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
    [appDelegate.navigationController setNavigationBarHidden:NO animated:YES];

    [UIView beginAnimations:@"ShowTabbar" context:nil];
    [UIView setAnimationDuration:.2];
    self.view.frame = CGRectMake(0,0,320,368);
    [UIView commitAnimations];
}   
}
温柔少女心 2024-08-05 22:43:20

我的解决方案:

// Hide tab bar animated
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionFade];
[[self.view.window layer] addAnimation:animation forKey:@"layerAnimation"]; 
[self.tabBarController.tabBar setHidden:YES];

// Display tab bar animated
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionFade];
[[self.view.window layer] addAnimation:animation forKey:@"layerAnimation"]; 
[self.tabBarController.tabBar setHidden:NO];

您必须添加 #import

My solution:

// Hide tab bar animated
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionFade];
[[self.view.window layer] addAnimation:animation forKey:@"layerAnimation"]; 
[self.tabBarController.tabBar setHidden:YES];

// Display tab bar animated
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionFade];
[[self.view.window layer] addAnimation:animation forKey:@"layerAnimation"]; 
[self.tabBarController.tabBar setHidden:NO];

You have to add #import <QuartzCore/QuartzCore.h>

行至春深 2024-08-05 22:43:20

我找到了这个问题的一个答案,非常简单且有效。

解决方案是在应用程序的所有视图、视图控制器和选项卡栏控制器中设置选项“按下时隐藏底部栏”

无论如何,您可以在 IB 中或通过代码来完成此操作。

希望这对大家有帮助...

I´ve found one answer to this issue, is very simple and effective.

The solution is to set the option "Hides Bottom Bar on Push" in ALL VIEWS, VIEW CONTROLLERS and TAB BAR CONTROLLERS of your app.

You can do this in IB or by code anyway.

Hope you this helps everyone...

站稳脚跟 2024-08-05 22:43:20

为了调整窗口的大小,您首先需要在检查器窗口的“属性”选项卡下的状态栏字段中选择“无”选项。 然后,Interface Builder 将允许您更改窗口的大小。

In order to adjust the size of your window, you first need to select the option of NONE in the status bar field, under your Attributes tab, of your Inspector window. Interface Builder will then let you change the size of your window.

沦落红尘 2024-08-05 22:43:20

如果有人需要 MonoTouch 版本操作系统,可以使用这个很酷的小技巧。 (谢谢!)

    // Method implementations
    static void hideTabBar (UITabBarController tabbarcontroller)
    {
        UIView.Animate(0.4, delegate() { 
            foreach(UIView view in tabbarcontroller.View.Subviews)
            {
                if(view.GetType()==typeof(UITabBar))
                    view.Frame=new  RectangleF(view.Frame.X, 480, view.Frame.Size.Width, view.Frame.Size.Height);
                else 
                    view.Frame=new  RectangleF(view.Frame.X, view.Frame.Y, view.Frame.Size.Width, 480);
            }
        });
    }

    static void showTabBar (UITabBarController tabbarcontroller)
    {
        UIView.Animate(0.4, delegate() { 
            foreach(UIView view in tabbarcontroller.View.Subviews)
            {
                if(view.GetType()==typeof(UITabBar))
                    view.Frame=new  RectangleF(view.Frame.X, 367, view.Frame.Size.Width, view.Frame.Size.Height);
                else 
                    view.Frame=new  RectangleF(view.Frame.X, view.Frame.Y, view.Frame.Size.Width, 367);
            }
        });
    }

In case any one needs the MonoTouch version os this cool little trick. (thanks!)

    // Method implementations
    static void hideTabBar (UITabBarController tabbarcontroller)
    {
        UIView.Animate(0.4, delegate() { 
            foreach(UIView view in tabbarcontroller.View.Subviews)
            {
                if(view.GetType()==typeof(UITabBar))
                    view.Frame=new  RectangleF(view.Frame.X, 480, view.Frame.Size.Width, view.Frame.Size.Height);
                else 
                    view.Frame=new  RectangleF(view.Frame.X, view.Frame.Y, view.Frame.Size.Width, 480);
            }
        });
    }

    static void showTabBar (UITabBarController tabbarcontroller)
    {
        UIView.Animate(0.4, delegate() { 
            foreach(UIView view in tabbarcontroller.View.Subviews)
            {
                if(view.GetType()==typeof(UITabBar))
                    view.Frame=new  RectangleF(view.Frame.X, 367, view.Frame.Size.Width, view.Frame.Size.Height);
                else 
                    view.Frame=new  RectangleF(view.Frame.X, view.Frame.Y, view.Frame.Size.Width, 367);
            }
        });
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文