         guard index >= _rootViewControllersInfo.viewControllers.startIndex && index < _rootViewControllersInfo.viewControllers.endIndex else {
             return
         }
-        
+        _rootViewControllersInfo.selectedIndex = index
         let _selectedViewController = _rootViewControllersInfo.viewControllers[index]
         
         _contentScrollView.scrollRectToVisible(_selectedViewController.view.frame, animated: true)

            return objc_getAssociatedObject(self, &_TabNavigationItemsObjectKey.key) as! [TabNavigationItem]
        }
        set { objc_setAssociatedObject(self, &_TabNavigationItemsObjectKey.key, newValue, .OBJC_ASSOCIATION_COPY_NONATOMIC) }
    }
}


        // Add to child view controllers.
        addChildViewController(viewController)
        if _viewControllersStack.isEmpty {
            _contentScrollView.isScrollEnabled = false
            _panGestureRecognizer.isEnabled = true
            tabNavigationBar.showNavigationBackItem(animated)
            // Record the selected index of the root view controllers.
            _rootViewControllersInfo.selectedIndex = tabNavigationBar.selectedIndex
        }
        _viewControllersStack.append(viewController)
        view.insertSubview(viewController.view, belowSubview: tabNavigationBar)
        
        if viewController.view is UIScrollView {
