Minitour / AZTabBarController

A custom tab bar controller for iOS written in Swift 4.2
MIT License
348 stars 65 forks source link

Move to different Index from a ViewController #39

Closed mogsten closed 6 years ago

mogsten commented 6 years ago

How can I move to a different Index from a ViewController?

If I click on the button on the TabBar, it works fine. But I need to programmatically move to the view controller when a function has finished. Is this possible?

Minitour commented 6 years ago

@mogsten There you go

self.currentTabBar?.setIndex(2, animated: false)
mogsten commented 6 years ago

Hello,

How do I get currentTabBar? I am not loading from a ViewController on the tab bar, I am loading from a page that has been pushed from a UINavigationController that was on the TabBar?

Minitour commented 6 years ago

currentTabBar is an extension variable for UIViewController. As long as you have an AZTabBarController in the hierarchy you should be fine. Whatever your page is, if it is a sub class of UIViewController you should have access to currentTabBar.