Skip to content

Instantly share code, notes, and snippets.

@michaelarmstrong
Created November 24, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelarmstrong/afc0a655117db486278f to your computer and use it in GitHub Desktop.
Save michaelarmstrong/afc0a655117db486278f to your computer and use it in GitHub Desktop.
Weird way to find if a view controller is modally presented.
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