material-components-ios icon indicating copy to clipboard operation
material-components-ios copied to clipboard

[BottomNavigation] [Beta] MDCBottomNavigationController should inform child UIVIewControllers of appearance transitions

Open CapnSpellcheck opened this issue 5 years ago • 0 comments

For usage questions: ask on Stack Overflow.

Reproduction steps

Steps to reproduce the behavior:

  1. Create a bottom nav controller and set view controllers
  2. Tap on a different tab, say tab B
  3. Tap back to original tab
  4. 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;

CapnSpellcheck avatar Jul 02 '20 03:07 CapnSpellcheck