Using isMotionEnabled on BottomNavigationController/UITabBarController causes delegate methods to not be called
andrewc94 opened this issue · comments
It seems as though setting the delegate on a BottomNavigationController causes Motion to be disabled while enabling Motion causes delegate methods to not be called.
Material 2.13.5
Motion 1.3.4
I will take a look at your sample. Thank you for sharing this issue.
@OrkhanAlikhanov Let's confirm if this is still an issue. Thank you and apologies for taking a very long time to respond.
@DanielDahan I confirm that this issue is still there. I investigated it a bit. Here is my summary.
The issue
Setting isMotionEnabled = true
changes the delegate
but does not forward the delegation methods to previousTabBarDelegate
.
class AppBottomNavigationController: BottomNavigationController {
override func prepare() {
super.prepare()
delegate = self
print(delegate === self) // true
isMotionEnabled = true // changes `delegate`
print(delegate === self) // false
isMotionEnabled = false // sets `previousTabBarDelegate` back
print(delegate === self) // true
}
}
extension AppBottomNavigationController: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
print("hi") // never called if `isMotionEnabled == true`
}
}
Possible solution
I think forwarding delegation methods to the tabBarController.previousTabBarDelegate
will solve the problem but I am unsure about its side effects. Here is the file where it should be done.
@OrkhanAlikhanov I believe this issue may be closed. Please take a look at Motion 1.4.2 to test if this is still an issue. Thank you!