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。 –
我已經更新了答案,請檢查 –