该文件位于:
//MARK: - UITabBarControllerDelegate
func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) {
if viewController == tabBarController.moreNavigationController {
tabBarController.moreNavigationController.delegate = self
} else {
findSelectedTagForTabBarController(tabBarController)
}
}
//MARK: - UINavigationControllerDelegate
func navigationController(navigationController: UINavigationController, didShowViewController viewController: UIViewController, animated: Bool) {
findSelectedTagForTabBarController(navigationController.tabBarController)
}
//MARK: - Private
private func findSelectedTagForTabBarController(tabBarController: UITabBarController?) {
if let tabBarController = tabBarController {
if let viewControllers = tabBarController.viewControllers {
let selectedIndex = tabBarController.selectedIndex
let selectedController: UIViewController? = viewControllers.count > selectedIndex ? viewControllers[selectedIndex] : nil
if let tag = selectedController?.tabBarItem.tag {
//here you can use your tag
}
}
}
}
可以在这里查看: https://github.com/woothemes/woocommerce/blob/master/includes/wc-page-functions.php
有一个功能namaed wp-content/plugins/woocommerce/includes/wc-page-functions.php
显然用于分配wc_nav_menu_item_classes
& 'current-menu-item'
类到菜单项。
在我的导航菜单中,我有主要的SHOP链接,其中显示了所有类别及其与产品的链接。当我选择类别/子类别或单个产品时,它不会突出显示菜单中的主要SHOP链接。我能够通过在上述函数中添加2行代码来解决这个问题:
'current_page_item'
现在,当我在主导航菜单中添加类别链接时,在查看与该类别相关的子类别或单个产品时,它不会突出显示菜单项。我该如何解决这个问题?