开发者

Hide tab bar control in tabbar project

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 = 开发者_StackOverflow社区YES;

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

Thanks


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.


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 :)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜