When the UITableView
cell is clicked, popup menu appears from bottom with animation and covers tab bar.
I want to prevent tab bar item's click event when cell is clicked and popup menu is appearing.
So I made a custom UITabBarController
which comforms UITabBarContorllerDeleagte
like below
// CustomTabBarController.swift
class CustomTabBarController: UITabBarController, UITabBarControllerDelegate {
var enabled = true
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
return enabled
}
}
instance property enabled
is set to false when table cell is clicked and to true when popup menu disappears.
The problem is that when I click cell and tab bar sequentially very quickly, popup menu appears and also tab is changed. I think tab bar item click event is executed before variable enabled
's change.
Using UITabBarController
's isUserInteractionEnabled
and disable each tab bar item have a same result. How can I fix this?