Created
November 24, 2015 16:38
-
-
Save michaelarmstrong/afc0a655117db486278f to your computer and use it in GitHub Desktop.
Weird way to find if a view controller is modally presented.
This file contains 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
func isModal() -> Bool { | |
if let presentingViewController = self.presentingViewController { | |
return true | |
} | |
if let presentingViewController = self.presentingViewController?.presentedViewController { | |
let exists = (presentingViewController === self) | |
if exists { return true } | |
} | |
if let presentedNavViewController = self.navigationController?.presentingViewController?.presentedViewController { | |
let exists = (presentedNavViewController === self) | |
if exists { return true } | |
} | |
if let tabBarController = self.tabBarController?.presentingViewController?.isKindOfClass(UITabBarController) { | |
return true | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment