material-components-ios
material-components-ios copied to clipboard
[BottomNavigation] [Beta] MDCBottomNavigationController should inform child UIVIewControllers of appearance transitions
For usage questions: ask on Stack Overflow.
Reproduction steps
Steps to reproduce the behavior:
- Create a bottom nav controller and set view controllers
- Tap on a different tab, say tab B
- Tap back to original tab
- Tap back to tab B
Expected behavior
View controller of tab B receives viewWillAppear: followed by viewDidAppear: after step 2 and 4. Similarly controller of tab A receives viewWillDisappear: etc.
Actual behavior
View controller of tab B receives viewWillAppear: followed by viewDidAppear: after step 2 only.
Platform (please complete the following information)
- Device: [ iPhone8]
- OS: iOS12.2]
Additional context
Patching the code to this works for me:
// Remove current VC and add new one.
[self.selectedViewController beginAppearanceTransition:NO animated:NO];
[self.selectedViewController.view removeFromSuperview];
[self.selectedViewController endAppearanceTransition];
[selectedViewController beginAppearanceTransition:YES animated:NO];
[self.content addSubview:selectedViewController.view];
[self addConstraintsForChildViewControllerView:selectedViewController.view];
[selectedViewController endAppearanceTransition];
// Set the iVar and update selected index
_selectedViewController = selectedViewController;