I can\'t seem to get the top most UIViewController without access to a UINavigationController. Here is what I have so far:
UIApplic
To find the visible viewController in Swift 3
if let viewControllers = window?.rootViewController?.childViewControllers {
let prefs = UserDefaults.standard
if viewControllers[viewControllers.count - 1] is ABCController{
print("[ABCController] is visible")
}
}
This code find the last added or the last active controller visible.
This I have used in AppDelegate to find active view Controller