-4

here is the source code

  1. problem: TabbarController is not working properly... please help me

    NSArray *actionButtonItems = @[searchItem, refreshItem];
    
    self.navigationItem.rightBarButtonItems = actionButtonItems;
    
    
    
    NSMutableArray *items = [[NSMutableArray alloc] init];
    
    
    [items addObject:[[UITabBarItem alloc]
                       initWithTabBarSystemItem:UITabBarSystemItemHistory tag:1]];
    
    [items addObject:[[UITabBarItem
                       alloc]initWithTabBarSystemItem:UITabBarSystemItemContacts  tag:2]];
    
    tabBar.items = items;
    
    tabBar.delegate = self;
    
    addFriends = [[AddFriendsViewController alloc]          initWithNibName:@"AddFriendsViewController" bundle:nil];
    
    [self.tabView addSubview:addFriends.view];
    
    //[self.tabsetSelectedIndex = 0];
    
    _tabBarController.selectedIndex = 0;
    
    [self.view addSubview:_tabBarController.view];
    
  • 2
    What is your problem? What have you tried to fix it? – damirstuhec Mar 03 '14 at 10:26
  • Here is the what you are finding for? http://stackoverflow.com/questions/2677698/android-iphone-style-tabhost –  Mar 03 '14 at 10:36
  • 1
    Well until you tell us the exact problem there isn't much we can do. What exactly is happening? And @BK what does that link have to do with anything??? – Popeye Mar 03 '14 at 10:40
  • @Popeye i am trying to help... –  Mar 03 '14 at 10:45
  • 1
    @BK and I'm trying to find out how that link helps. All I am after is a explanation since this question is very unclear I'm not sure how you could possible supply something so I'm just asking for more information. – Popeye Mar 03 '14 at 10:47
  • ohk @Popeye i made a guess... :) –  Mar 03 '14 at 10:49
  • 1
    @BK that's fine, if it was an answer it would have been downvoted though due to lack of information but that's what comments can be used for guessing, if your information is worthless then it's not affecting anyone. I just wanted to know if you had anything to go with it. – Popeye Mar 03 '14 at 10:51
  • My answer didn't work? – Oleg Sobolev Mar 03 '14 at 11:04

2 Answers2

1

Before you call

[self.tabView addSubview:addFriends.view];

you should call

[self.tabView setViewControllers:[NSArray arrayWithObjects: addFriends, nil]];
Oleg Sobolev
  • 3,286
  • 2
  • 16
  • 29
0

Set selectedViewController property of UITabBarController:

  self.myTabBarController.selectedViewController = myViewController;

Use as below

  self.myTabBarController.selectedViewController 
     = [self.myTabBarController.viewControllers objectAtIndex:0];