Skip to content

Commit

Permalink
Remove the old selected view controller from the view hierarchy when …
Browse files Browse the repository at this point in the history
…switching selected view controller, and add accessibility post notifications when switching selected view controllers so that VoiceOver will always switch to a new element visible on screen.

PiperOrigin-RevId: 327825660
  • Loading branch information
afweiss authored and material-automation committed Aug 21, 2020
1 parent 3643063 commit c8d8757
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/Tabs/src/MDCTabBarViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ - (void)updateOldSelectedViewController:(nullable UIViewController *)oldSelected
NSAssert([_viewControllers containsObject:selectedViewController], @"not one of us.");
}

[oldSelectedViewController willMoveToParentViewController:nil];
[oldSelectedViewController.view removeFromSuperview];
[oldSelectedViewController removeFromParentViewController];

if (![self.childViewControllers containsObject:selectedViewController]) {
[self addChildViewController:selectedViewController];
UIView *view = selectedViewController.view;
Expand All @@ -231,6 +235,8 @@ - (void)updateOldSelectedViewController:(nullable UIViewController *)oldSelected
self.tabBar.selectedItem = selectedViewController.tabBarItem;
}
[self setNeedsStatusBarAppearanceUpdate];

UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
}

- (void)setSelectedViewController:(nullable UIViewController *)selectedViewController {
Expand Down

0 comments on commit c8d8757

Please sign in to comment.