UItabBar changing View Controllers

时光总嘲笑我的痴心妄想 提交于 2019-11-29 13:55:23

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!