eggswift / ESTabBarController

:octocat: ESTabBarController is a Swift model for customize UI, badge and adding animation to tabbar items. Support lottie!
MIT License
5.18k stars 581 forks source link

Issues with ShouldHijackHandler and DidHijackHandler #182

Closed pives closed 4 years ago

pives commented 5 years ago

I subclassed ESTabBarController and having trouble with the HijackHandlers. I looked at the example project and I can't figure out what's going on.

The hijack does fire correctly and run but the tab bar is switching viewControllers before it does that. I want it to stay on the same selected item.

shouldHijackHandler = { _, _, index in if index == 4 { return true } return false } didHijackHandler = { [weak self] tabBarController, viewController,index in ... do stuff }

This is the relevant Tab definition:

var keyboardTabVC: KeyboardTabVC = { let keyboardTabVC = KeyboardTabVC() keyboardTabVC.tabBarItem = ESTabBarItem(TabBarBasicView(), title: nil, image: UIImage(named: "icKeyboard"), selectedImage: UIImage(named: "icKeyboardSelected")) return keyboardTabVC }()

eggswift commented 5 years ago

I cannot get you! More detail please

lindseypisaak commented 5 years ago

@eggswift I think this is the same issue I'm running into

I'd like to be able to hijack the tap of a tab bar item and show the selected image until whatever task/flow is completed. Right now it seems impossible to have a "selected" image while you have something shown from a hijacked tab press

eggswift commented 5 years ago

Ohh, because the hijack item should not have select state, It's always like a button. I think, as a hijack-able item, the select action did finished. So it cannot still in select state. Maybe you can try update your tabbar item content's ui manully.

pives commented 5 years ago

is there any way to intercept and then not select the item?

eggswift commented 5 years ago

Try to set 'selectIndex' manually?