A
A
Anton Parfenov2016-03-10 13:49:33
iOS
Anton Parfenov, 2016-03-10 13:49:33

How to access UITabBarController from external controller?

The essence of the problem is as follows, there is an application with tabs, when you click on one of the tabs, the login controller opens, through the storyboard by id
And after closing it, I need to switch the tab, for example, to the second one programmatically ...
I tried like this:
self.tabBarController?.selectedIndex = 1
and like this:

let TBC: UITabBarController = self.storyboard?.instantiateViewControllerWithIdentifier("TBC") as! TabBarController
TBC.selectedIndex = 1

How else can you contact him?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
ManWithBear, 2016-03-10
@goldbest

It is possible, and even better, to pass the login to the controller block to complete. And when your popup controller is done, it will execute the corresponding block.
UPD.
1) Add a clajour variable to your popup:
2) When creating a popup, add a callback to it:

popup.callback = {(successful:Bool)->Void in
    if successful {
        // something
    } else {
        // something
    }
}

3) When everything is ready, execute the callback:
if let callback = callback {
    callback(successful: true)
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question