0

how to connect them. How do i place the TABBAR control on top of view control.by default it is at bottom how do i put it up..?

Used following code to do:

 UIImage* tabBarBackground = [UIImage imageNamed:@"footer-bg.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
[[UITabBar appearance]setSelectionIndicatorImage:[UIImage imageNamed:@"footer-hover-bg.png"]];

if(IS_IOS_7)
{
    [[appDelegate.tabBarController tabBar] setSelectionIndicatorImage:[UIImage imageNamed:@"footer-hover-bg.png"]];
    [[UITabBar appearance] setTintColor:[UIColor blackColor]];
}
appDelegate.tabBarController.tabBar.frame = CGRectMake(0, 20, 320, 50);
appDelegate.tabBarController.delegate=self;

UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, -20, 320, 600)];

viewControllers = [[NSMutableArray alloc] init];

MainViewController *view1 = [[MainViewController alloc] init];
UINavigationController *nav1=[[UINavigationController alloc]initWithRootViewController:view1];
[viewControllers addObject:nav1];

ViewController1 *view2 = [[ViewController1 alloc] init];
UINavigationController *nav2=[[UINavigationController alloc]initWithRootViewController:view2];
[viewControllers addObject:nav2];

[appDelegate.tabBarController setViewControllers:viewControllers];

appDelegate.tabBarController.tabBarController.view.frame=CGRectMake(0, 0, 320, 480);
[view addSubview:appDelegate.tabBarController.view];

[self.view addSubview:view];

UITabBarItem *tabBarItem1 = [appDelegate.tabBarController.tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [appDelegate.tabBarController.tabBar.items objectAtIndex:1];


[tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:[arraySelectedImages objectAtIndex:0]] withFinishedUnselectedImage:[UIImage imageNamed:[arrayUnselectedImages objectAtIndex:0]]];
[tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:[arraySelectedImages objectAtIndex:1]] withFinishedUnselectedImage:[UIImage imageNamed:[arrayUnselectedImages objectAtIndex:1]]];

How do i do the same using storyboards?

user2798258
  • 171
  • 1
  • 4
  • 13

1 Answers1

3

First add a UIViewController then add the UITabBar and add contraint if you use autolayout.

enter image description here

Don't forgot to connect delegate.

Hope that will help.

Nicolas Bonnet
  • 1,275
  • 11
  • 15
  • i have used UITabBarController and added views to it.can i change its frame so that i can add it above. – user2798258 Feb 25 '14 at 11:00
  • No. If you use UITabBarController you will be not able to change the position – Nicolas Bonnet Feb 25 '14 at 12:07
  • can u please give me sample links for Tabbar using storyboards.I couldn't find :( – user2798258 Feb 25 '14 at 12:56
  • a beginning : http://nullpointr.wordpress.com/2012/02/18/ios-dev-add-tabbar-to-a-view-without-a-tabbarcontroller/ – Nicolas Bonnet Feb 25 '14 at 13:06
  • Thanks a lot :).How do i connect first view controller with the first tabbaritem in a stroyboard?.I am not able load view controller. – user2798258 Feb 26 '14 at 06:33
  • the first view will be the current view ^^ – Nicolas Bonnet Feb 26 '14 at 07:45
  • this code doesnt work - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { switch (item.tag) { case 1: if (tab1vc == nil) { UIStoryboard *storyBoard=[UIStoryboard storyboardWithName:@"Main" bundle:Nil]; mainTabbar = [storyBoard instantiateViewControllerWithIdentifier:@"FirstViewController"]; // self.tab1vc =[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil]; } [self.view insertSubview:tab1vc.view belowSubview:mainTabBar]; break; – user2798258 Feb 26 '14 at 09:59
  • it is not related to my question :( there is no tabbar init. – user2798258 Feb 26 '14 at 10:36
  • don't build your app as `UITabBarController` because you DON'T have a UITabBarController. just navigate in the app without an `NavigationController` or `UITabBarController` like in this answer... – Nicolas Bonnet Feb 26 '14 at 12:03