OUR BLOG

19 Nov 2020

iOS App开发 导航 TabBar 点击实现刷新

最简单的方法,其实只要重写UITabBarController的代理就可以实现,如下

extension MainTabBarController: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {

if (viewController.isEqual(tabBarController.viewControllers?.first)){
if(viewController.isEqual(tabBarController.selectedViewController)){
let home = viewController.children[0] as! HomeController
home.handleRefresh()
return false
}
}

return true
}

}

admin