Closed alouanemed closed 4 years ago
@alouanemed Hey, it seems that it already should work as you expect. Please take a look at source code:
if selectedIndex != currentIndex {
let previousItem = items.at(selectedIndex)
let previousContainer: UIView? = previousItem?.iconView?.icon.superview
previousContainer?.backgroundColor = items[selectedIndex].bgDefaultColor
previousItem?.deselectAnimation()
let currentItem: RAMAnimatedTabBarItem = items[currentIndex]
currentItem.playAnimation()
let currentContainer: UIView? = currentItem.iconView?.icon.superview
currentContainer?.backgroundColor = items[currentIndex].bgSelectedColor
selectedIndex = index
} else {
if let navVC = viewControllers?[selectedIndex] as? UINavigationController {
navVC.popToRootViewController(animated: true)
}
}
If user select on same item second time and current view controller is UINavigationController it will pop to root view controller. Please let me know if you have any problem with this logic
although I am using the latest version in my project, nothing happens when I tap multiple times on an item. what do you think? How can I debug this?
Thanks.
Please take a look at double-tap-example
branch, I've add example how it works.
Each time you tap on the screen next view controller will be pushed, and then if you press selected tab bar item it will pop to root view controller.
For the else statement when you say "If user select on same item second time and current view controller is UINavigationController it will pop to root view controller", how do we access that for a custom animation class?
Also, I tried to add print statements to see when the else statement runs but it doesn't run when I tap an already selected tab bar item. Why is that?
Is there any method on which I can pop the root controller when a tab bar item tapped twice, similar to the behavioir on Instagram.