UItabBar changing View Controllers

后端 未结 1 1299
悲&欢浪女
悲&欢浪女 2020-12-20 19:08

i have some difficulties changing tab bar controllers. Basically I have UITabBarController with 3 controllers. First time when app starts. I change one controller like this:

相关标签:
1条回答
  • 2020-12-20 20:05

    First I assume you meant:

    [self.tabBarController setSelectedIndex:1];
    

    Failing that it sounds like the problem is with your _tabBarControllers.

    what do the following output:

    NSLog(@" _tabBarControllers count = %d", [_tabBarControllers count]);
    NSArray* newArray = [NSArray arrayWithArray:self.tabBarController.viewControllers];
    NSLog(@" newArray count = %d", [newArray count]);
    

    EDIT: Does the following successfully remove the first tab with no problems?

    NSMutableArray* newArray = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
    [newArray removeObjectAtIndex:0]; 
    [self.tabBarController setViewControllers:newArray animated:YES];
    

    EDIT 2 :

    try changing:

    [muteArray addObjectsFromArray:_navigationCotroller.viewControllers];
    online.tabBarControllers = [muteArray copy];
    [muteArray replaceObjectAtIndex:1 withObject:online];
    

    to:

    [muteArray addObjectsFromArray:self.tabBarController.viewControllers];
    [muteArray replaceObjectAtIndex:1 withObject:online];
    online.tabBarControllers = [muteArray copy];
    

    To be honest I'm finding it hard to follow your app structure and object references.

    0 讨论(0)
提交回复
热议问题