2
我已经使用以下tutorial在ios中实现自定义选项卡 当我点击任何项目时,它的工作正常。现在我想以编程方式移动它。例如我收到Firebase通知表单,并想要打开第三个标签。但我得到零。我参考了appdelegate
中的MainTabbarController
实例。 以下是我已经尝试 在CustomTabBar
以编程方式选择标签自定义标签栏ios
func customTapped(index :Int){
animateTabBarSelection(from: selectedTabBarItemIndex, to: index)
selectedTabBarItemIndex = index
delegate.didSelectViewController(self, atIndex: index)
}
在AppDelegate
mainTabBarController?.customTabBar?.customTapped(index: 2)
你是否试图从AppDelegate中调用它。我得到零。调试器说CustomTabBar的selectedTabBarItemIden是nill –
这意味着没有任何先前选择的项目。所以在这种情况下,您可能不必正确显示动画。因此,如果selectedTabBarItemIndex为零,则可以跳过该语句animateTabBarSelection。 –
我已经更新了答案,请检查 –