我可以使用 TabBarItem 上的自定义事件点击来制作自定义 UITabBarController 吗?
Can i make custom UITabBarController with custom event tap on TabBarItem?
我需要显示 UITabBarController
,但我不需要它来将我从 viewControllers
数组切换到控制器。我可以重新分配活动还是自己创建这样的活动会更好 TabBarController
?
您可以为UITabBarController创建一个子类并确认UITabBarControllerDelegate
然后您可以在 shouldSelect 方法中执行自定义选项卡部分操作。
func tabBarController(_ tabBarController: UITabBarController,
shouldSelect viewController: UIViewController) -> Bool
{
if viewController == secondViewController {
//Do your actions
return false
}
return true
}
我需要显示 UITabBarController
,但我不需要它来将我从 viewControllers
数组切换到控制器。我可以重新分配活动还是自己创建这样的活动会更好 TabBarController
?
您可以为UITabBarController创建一个子类并确认UITabBarControllerDelegate
然后您可以在 shouldSelect 方法中执行自定义选项卡部分操作。
func tabBarController(_ tabBarController: UITabBarController,
shouldSelect viewController: UIViewController) -> Bool
{
if viewController == secondViewController {
//Do your actions
return false
}
return true
}