Skip to content

Instantly share code, notes, and snippets.

@trinnguyen
Created July 15, 2018 09:00
Show Gist options
  • Save trinnguyen/7a7d840048abf1cb1429a2cb9275fd2e to your computer and use it in GitHub Desktop.
Save trinnguyen/7a7d840048abf1cb1429a2cb9275fd2e to your computer and use it in GitHub Desktop.
Xamarin ios check wether a ViewController is presented as Modal. Support NavigationController (not TabBar)
public static bool CheckIsModalVC(UIViewController viewController)
{
// find root
var vc = viewController;
while (vc.NavigationController != null)
{
vc = vc.NavigationController;
}
// check cur
if (vc.PresentingViewController != null)
{
return vc.PresentingViewController.PresentedViewController == vc;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment