Reputation: 5106
I am now doing sign in/sign out feature for my app.When i try to sign out,i want to called the current view controller ViewDidAppear().Because I want to refresh the view to lock that label that are only available for sign in user.So I need to know which current view controller that is displaying in my app. Any help?
Upvotes: 0
Views: 578
Reputation: 6775
If you are in navigation controller, you can get the VC on top.
self.navigationController?.topViewController
will return you the ViewController on top of the stack.
You can check this for other options.
To point a few:
var topViewController: UIViewController?
The view controller at the top of the navigation stack.
var visibleViewController: UIViewController?
The view controller associated with the currently visible view in the navigation interface.
var viewControllers: [UIViewController]
The view controllers currently on the navigation stack.
Upvotes: 1