Created
May 19, 2018 19:36
-
-
Save harrysummers/430bc09387f45c3e5801bd6312852fb1 to your computer and use it in GitHub Desktop.
Get currently active view controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate func getShowingViewController(_ rootViewController: UIViewController) -> UIViewController? { | |
var isRoot = false | |
var showViewController: UIViewController? = rootViewController | |
while (!isRoot) { | |
if let tempViewController = showViewController?.presentedViewController { | |
showViewController = tempViewController | |
} else { | |
isRoot = true | |
} | |
} | |
return showViewController | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment