在选项卡栏项目中隐藏选项卡栏控件

发布于 2024-09-17 07:08:26 字数 276 浏览 21 评论 0原文

我正在开发一个标签栏项目,在这个项目中我也有导航控制器。我正在执行以下步骤:- 显示主屏幕 从第一个选项卡导航到接下来的 5 个屏幕。 在第六个屏幕上,我想显示选项卡控制器并想显示我的其他选项卡栏。 我尝试了下面的代码:-

self.navigationController.tabBarController.hidesBottomBarWhenPushed = YES;

和其他一些代码。但尚未取得任何成功。那么有人可以建议我如何做到这一点吗?

谢谢

I am working on a tabbar project and in this i also have navigation controller. and i am doing below steps :-
Show the main screen
navigation from first tab to 5 next screens.
and on the 6th screen i want to show the tabbarcontroller and want to show my other tab bar.
i tried the below code :-

self.navigationController.tabBarController.hidesBottomBarWhenPushed = YES;

and some others. but did not get any success yet. so can any one suggest how to i do this?

Thanks

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

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

发布评论

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

评论(3

墨小沫ゞ 2024-09-24 07:08:26

创建两个文件 .h 和 .m,不带 .xib

//.h file
#import <UIKit/UIKit.h>

@class Class1, Class2;
@interface TabbarController : UITabBarController 
{
        Class1 *class1;
    Class2 *class2;
    UINavigationController *nav1,*nav2;
}
@end

//.m 文件

@implementation TabbarController

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad 
{
    [super viewDidLoad];

    class1 =[[Class1 alloc] initWithNibName:@"Class1" bundle:nil];
    nav1=[[UINavigationController alloc] initWithRootViewController:class1];
    class1.title = @"class1";
    class1.tabBarItem.image = [UIImage imageNamed:@"tab1.png"];
    class1.navigationController.navigationBar.hidden = TRUE;

    class2 =[[Class2 alloc] initWithNibName:@"Class2" bundle:nil];
    nav2=[[UINavigationController alloc] initWithRootViewController:class2];
    class2.tabBarItem.image = [UIImage imageNamed:@"tab2.png"];
    class2.title = @"class2";
    class2.navigationController.navigationBar.hidden = TRUE;

    NSArray *controllers = [NSArray arrayWithObjects:nav1,nav2,nil];
    self.viewControllers = controllers;
}

将视图重定向到需要选项卡栏的位置。

Create two files .h and .m without .xib

//.h file
#import <UIKit/UIKit.h>

@class Class1, Class2;
@interface TabbarController : UITabBarController 
{
        Class1 *class1;
    Class2 *class2;
    UINavigationController *nav1,*nav2;
}
@end

//.m file

@implementation TabbarController

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad 
{
    [super viewDidLoad];

    class1 =[[Class1 alloc] initWithNibName:@"Class1" bundle:nil];
    nav1=[[UINavigationController alloc] initWithRootViewController:class1];
    class1.title = @"class1";
    class1.tabBarItem.image = [UIImage imageNamed:@"tab1.png"];
    class1.navigationController.navigationBar.hidden = TRUE;

    class2 =[[Class2 alloc] initWithNibName:@"Class2" bundle:nil];
    nav2=[[UINavigationController alloc] initWithRootViewController:class2];
    class2.tabBarItem.image = [UIImage imageNamed:@"tab2.png"];
    class2.title = @"class2";
    class2.navigationController.navigationBar.hidden = TRUE;

    NSArray *controllers = [NSArray arrayWithObjects:nav1,nav2,nil];
    self.viewControllers = controllers;
}

Redirect your view to this view wherever you need tabbar.

思念满溢 2024-09-24 07:08:26

通过以下方式尝试:

创建委托类的对象

#import "DelegateClass.h"


DelegateClass *appDel;

现在在 .m 类中

-(void)viewDidLoad
{
  [super viewDidLoad];

  appDel= (DelegateClass *)[[UIApplication sharedApplication]delegate];

}

现在只需在导航位置的视图中执行此操作,

appDel.tabBarController.hidesBottomBarWhenPushed = YES;

这只是一个棘手的部分。它对我来说非常有用:)

TRy it by this:

Create the Object of Delegate class

#import "DelegateClass.h"


DelegateClass *appDel;

Now in .m class

-(void)viewDidLoad
{
  [super viewDidLoad];

  appDel= (DelegateClass *)[[UIApplication sharedApplication]delegate];

}

Now just do like this in the View from where you are navigation,

appDel.tabBarController.hidesBottomBarWhenPushed = YES;

This was just a tricky part.It worked greatly for me :)

盗琴音 2024-09-24 07:08:26

您必须使用自定义UItabBarController
请参阅创建自定义 TabBar 控制器

You have to use custom UItabBarController.
see creating custom TabBar Controller

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文