0

I had an application in which i had a tab bar controller with 4 navigation controllers.

_tabbarcontroller = [[UITabBarController alloc] init];
_tabbarcontroller.viewControllers = [NSArray arrayWithObjects:vcontroller,xnav,ynav,znav,nil];

and everything works fine. Now I want to add a view over the selected viewcontroller when the 0th item selected in the tab bar; this must be over the tabbarcontroller. What I tried:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    NSUInteger selectedIndex = [_tabbarcontroller.viewControllers indexOfObject:self];
    UITabBar *tabBar = self.tabbarcontroller.tabBar;
    UITabBarItem *item0 = [tabBar.items objectAtIndex:0];

    if(tabBar.selectedItem==item0)
    {
        tabBarController.selectedIndex=selectedIndex;
        FViewController *fviewcontroller =[[FViewController alloc] initWithNibName:@"FViewController" bundle:nil];
        [_tabbarcontroller.view addSubview: fviewcontroller.view];
    }
}

But it doesn't seem right. I want it to be added over the present selected view controller and when selecting out side that small view needs to remove that also. can anybody guide me on this?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
hacker
  • 8,919
  • 12
  • 62
  • 108
  • What kind of view are you trying to display? Does it have multiple UIControl elements? Or, is it just to display static data? – GoGreen Apr 11 '14 at 14:02
  • @its a small view with 3 buttons ,by remaining as overlay...so that the background can be seen.. – hacker Apr 11 '14 at 14:16
  • you may refer to this [stackoverflow answer](http://stackoverflow.com/a/9046159/2954866). I think that is what you are looking for. – GoGreen Apr 11 '14 at 14:38

1 Answers1

0

Simple way to achieve this is use Popup and display with the 0th index of your tabbar controller. add this popup in
tabbarcontroller.selectedViewController.view when selected index of tabbarcontroller is 0.

Amit Bhavsar
  • 1,273
  • 12
  • 23