2010-09-06 127 views
1

我正在使用tabbar项目,在此我也有导航控制器。我正在执行以下步骤: - 显示主屏幕 从第一个标签导航到5个下一个屏幕。 和第6屏幕上,我想显示tabbarcontroller,并希望显示我的其他标签栏。 我试了下面的代码: -隐藏标签栏项目中的标签栏控件

self.navigationController.tabBarController.hidesBottomBarWhenPushed = YES; 

和其他一些。但还没有取得任何成功。所以任何人都可以提出如何做到这一点?

感谢

回答

0

你必须使用自定义UItabBarController。 看到creating custom TabBar Controller

+0

你的意思是自定义? – 2011-04-13 10:44:48

+0

http://iosdevelopertips.com/open-source/ios-open-source-custom-tabbar-controller-bctabbarcontroller.html – 2013-02-22 08:15:03

1

没有的.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; 
} 

创建两个文件的.h和.M重定向你的看法这一观点无论你需要的TabBar。

+0

无论你需要tabbar,你的视图重定向到这个视图。 – 2011-04-13 13:54:24

0

这个尝试:

创建委托类的对象

#import "DelegateClass.h" 


DelegateClass *appDel; 

现在的.m类

-(void)viewDidLoad 
{ 
    [super viewDidLoad]; 

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

} 

现在只是做这样的视图,从你在哪里导航,

appDel.tabBarController.hidesBottomBarWhenPushed = YES; 

这只是一个棘手的部分。它为我工作很好:)