i have added tab bar in app delegate. When i pushed the view from one of my view te tab bar got removed. I want that tab bar on pushed view also.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
AudioViewController * audioViewController = [[AudioViewController alloc] initWithNibName:@"AudioViewController" bundle:nil];
audioViewController.title = @"audio";
audioViewController.tabBarItem.image=[UIImage imageNamed:@"audio 30x30.png"];
ViewController *videoViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
videoViewController.title = @"video";
videoViewController.tabBarItem.image=[UIImage imageNamed:@"video 30x30.png"];
ViewController *aboutViewController = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
aboutViewController.title = @"about";
aboutViewController.tabBarItem.image=[UIImage imageNamed:@"about1_iPhone.png"];
ViewController *infoViewController = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
infoViewController.title = @"info";
infoViewController.tabBarItem.image=[UIImage imageNamed:@"info 30x30.png"];
PlaylistViewController *PlaylistViewControllerObj = [[PlaylistViewController alloc]initWithNibName:@"PlaylistViewController" bundle:nil];
PlaylistViewControllerObj.title = @"Playlist";
PlaylistViewControllerObj.tabBarItem.image=[UIImage imageNamed:@"ko.png"];
NSArray *viewControllerArray = [NSArray arrayWithObjects:audioViewController,videoViewController,aboutViewController,infoViewController,PlaylistViewControllerObj,nil];
UITabBarController * myTabbarController = [[UITabBarController alloc] init];
[myTabbarController setViewControllers:viewControllerArray];
navigationControllerObj = [[UINavigationController alloc] initWithRootViewController:myTabbarController];
[navigationControllerObj setNavigationBarHidden:YES animated:NO];
self.window.rootViewController =navigationControllerObj;
}
UIViewController *viewController1, *viewController2, *viewController3 , *viewController4 , *viewController5 ;
viewController1 = [[Homeviewcontroller alloc] initWithNibName:nil bundle:nil];
viewController2 = [[NearbyViewController alloc] initWithNibName:nil bundle:nil];
viewController3 = [[SearchViewController alloc] initWithNibName:nil bundle:nil];
viewController4 = [[FavoritiesViewController alloc] initWithNibName:nil bundle:nil];
viewController5 = [[MoreViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *homeNavi=[[UINavigationController alloc]initWithRootViewController:viewController1];
UINavigationController *SearchNavi=[[UINavigationController alloc]initWithRootViewController:viewController3];
UINavigationController *NearbyNavi=[[UINavigationController alloc]initWithRootViewController:viewController2];
UINavigationController *FavNavi=[[UINavigationController alloc]initWithRootViewController:viewController4];
UINavigationController *MoreNavi=[[UINavigationController alloc]initWithRootViewController:viewController5];
TabbarController = [[UITabBarController alloc] init];
TabbarController.viewControllers = [NSArray arrayWithObjects:homeNavi,SearchNavi,NearbyNavi,FavNavi,MoreNavi, nil];
[self presentModalViewController:TabbarController animated:YES];
Check value of this property in the UIViewController
you are pushing
@property(nonatomic) BOOL hidesBottomBarWhenPushed
Try this sample code
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
AudioViewController * audioViewController = [[AudioViewController alloc] initWithNibName:@"AudioViewController" bundle:nil];
audioViewController.title = @"audio";
audioViewController.tabBarItem.image=[UIImage imageNamed:@"audio 30x30.png"];
UINavigationController *navaudioViewController = [[UINavigationController alloc] initWithRootViewController:audioViewController];
PlaylistViewController *PlaylistViewControllerObj = [[PlaylistViewController alloc]initWithNibName:@"PlaylistViewController" bundle:nil];
PlaylistViewControllerObj.title = @"Playlist";
PlaylistViewControllerObj.tabBarItem.image=[UIImage imageNamed:@"ko.png"];
UINavigationController *navPlaylistView = [[UINavigationController alloc] initWithRootViewController:PlaylistViewControllerObj];
UITabBarController * myTabbarController = [[UITabBarController alloc] init];
myTabbarController.viewControllers = @[navHomeController,navPlaylistView];
self.window.rootViewController = myTabbarController;
[self.window makeKeyAndVisible];
return YES;
}
Use This Code
call this method , where to present UITabBar
In .h,
@property (strong, nonatomic) UINavigationController *navigation;
@property(nonatomic, strong) UITabBarController *tabbarcontroller;
In .m,
-(void)loadtabview
{
self.tabbarcontroller = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:4];
self.firstViewController = [[FirstViewController alloc]initWithNibName:@"firstViewController" bundle:nil];
navigation = [[UINavigationController alloc] initWithRootViewController:self.firstViewController];
self.viewController.navigationItem.title=@"First";
[localControllersArray addObject:navigation];
self.secondViewController = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil];
navigation = [[UINavigationController alloc] initWithRootViewController:secondViewController];
self.secondViewController.navigationItem.title=@"second";
[localControllersArray addObject:navigation];
self.ThirdViewController = [[Third ViewController alloc]initWithNibName:@"Third ViewController" bundle:nil];
navigation = [[UINavigationController alloc] initWithRootViewController:ThirdViewController];
self.secondViewController.navigationItem.title=@"Third";
[localControllersArray addObject:navigation];
tabbarcontroller.viewControllers = localControllersArray;
self.tabbarcontroller.delegate = self;
[self.tabbarcontroller setSelectedIndex:0];
[self.window addSubview:tabbarcontroller.view];
}