1

I have a custom UITabBarViewController and on click on the selected tabbaritem, I am trying to re-open/re-start the viewcontroller.

This is what it does on selecting a different tabbaritem..

if selectedIndex != currentIndex {
            let animationItem : RAMAnimatedTabBarItem = items[currentIndex]
            animationItem.playAnimation()

            let deselectItem = items[selectedIndex]

            let containerPrevious : UIView = deselectItem.iconView!.icon.superview!
            containerPrevious.backgroundColor = items[currentIndex].bgDefaultColor

            deselectItem.deselectAnimation()

            let container : UIView = animationItem.iconView!.icon.superview!
            container.backgroundColor = items[currentIndex].bgSelectedColor

            selectedIndex = gestureView.tag
            delegate?.tabBarController?(self, didSelectViewController: self)

        }

This is what I am trying to handle. I tried copying stuff from above chunk but doesn't seem to work for re-opening already selected view.

} else if selectedIndex == currentIndex {
       if let navVC = self.viewControllers![selectedIndex] as? UINavigationController {
             navVC.popToRootViewControllerAnimated(true)
        }

       // Restart/Reopen already selected TabBarView
}

Edit:

What I am trying to achieve is for example, if it's a TableViewController, restart tableView and fetch, and roll the page to the top (as it's re-opened).

Is there a method that directly handles restart view or should I handle stuff step by step ( i)pull view to top, ii)update tableview, etc)

senty
  • 12,385
  • 28
  • 130
  • 260

0 Answers0