在iPhone选项卡栏中重新加载选项卡并设置所选索引

在iPhone选项卡栏中重新加载选项卡并设置所选索引,iphone,uitabbarcontroller,Iphone,Uitabbarcontroller,我无法在选项卡栏中重新加载选项卡,然后选择正确的选项卡 当用户在我的应用程序中选择某个特定功能时——这意味着我需要重新加载屏幕底部的选项卡栏——有时需要添加按钮,有时需要删除按钮 我可以使用以下方式重新加载数据: [self.tabBarController setViewControllers:controllers animated:YES]; 但我无法使selectedViewIndex正常工作,它似乎被忽略了: self.tabBarController.selectedIndex =

我无法在选项卡栏中重新加载选项卡,然后选择正确的选项卡

当用户在我的应用程序中选择某个特定功能时——这意味着我需要重新加载屏幕底部的选项卡栏——有时需要添加按钮,有时需要删除按钮

我可以使用以下方式重新加载数据:

[self.tabBarController setViewControllers:controllers animated:YES];
但我无法使selectedViewIndex正常工作,它似乎被忽略了:

self.tabBarController.selectedIndex = [controllers count]-1;

我想选择最后一个选项卡-但在运行此代码后,它始终是选择的第一个选项卡-有什么想法吗?

我现在找到了一种方法,通过发出

[self.tabBarController.view setNeedsDisplay];
在调用selectedIndex后-但问题是屏幕闪烁,动画不是很好-还有其他想法吗