简体   繁体   中英

Can i make custom UITabBarController with custom event tap on TabBarItem?

I need to display the UITabBarController , but I don't need it to switch me to the Controller from the viewControllers array. Can I reassign the event or would it be better to create my own such TabBarController ?

You can create a subclass for UITabBarController and confirm to UITabBarControllerDelegate

Then you can perform custom tab section actions in shouldSelect method.

func tabBarController(_ tabBarController: UITabBarController, 
                  shouldSelect viewController: UIViewController) -> Bool
{
  if viewController == secondViewController { 
   //Do your actions
   return false
  }
  return true
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM