public void DeactivateController (bool animated) { var parent = ParentViewController; var nav = parent as UINavigationController; if (nav != null) nav.PopViewControllerAnimated (animated); else DismissModalViewControllerAnimated (animated); }