Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pop to root view controller every time tab is clicked ? #63

Closed
shanmarkus opened this issue Dec 1, 2015 · 3 comments
Closed

Pop to root view controller every time tab is clicked ? #63

shanmarkus opened this issue Dec 1, 2015 · 3 comments

Comments

@shanmarkus
Copy link

No description provided.

@MHX792
Copy link

MHX792 commented Dec 3, 2015

Came here to ask for this. +1

@MHX792
Copy link

MHX792 commented Dec 4, 2015

From another issue I got the following code:

func tapHandler(gesture:UIGestureRecognizer) {

    let items = tabBar.items as! [RAMAnimatedTabBarItem]

    let currentIndex = gesture.view!.tag
    let viewController = viewControllers![currentIndex]

    if let shouldSelect = delegate?.tabBarController?(self, shouldSelectViewController: viewController)
        where !shouldSelect {
        return
    }

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

        let deselelectIcon = iconsView[selectedIndex].icon
        let deselelectTextLabel = iconsView[selectedIndex].textLabel
        let deselectItem = items[selectedIndex]
        deselectItem.deselectAnimation(deselelectIcon, textLabel: deselelectTextLabel)
        selectedIndex = gesture.view!.tag
        delegate?.tabBarController?(self, didSelectViewController: viewController)
    } else {
        let animationItem : RAMAnimatedTabBarItem = items[currentIndex]
        let icon = iconsView[currentIndex].icon
        let textLabel = iconsView[currentIndex].textLabel
        animationItem.playAnimation(icon, textLabel: textLabel)

        selectedIndex = gesture.view!.tag
        delegate?.tabBarController?(self, didSelectViewController: viewController)
        viewController.navigationController?.popToRootViewControllerAnimated(true)
        print("viewController: \(viewController)") 
        // prints same instance as in the viewDidLoad method of the navigation controller of selected tab
    }
}

It successfully instantiates the navigation controller but unfortunately popToRootViewControllerAnimated doesn't work.

Anyone an idea how to fix this?

@0ber
Copy link
Contributor

0ber commented Jan 12, 2016

I don't understand the question, can you describe the problem more fully?

@0ber 0ber closed this as completed Apr 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants