Skip to content

Instantly share code, notes, and snippets.

@zmij
Created March 11, 2015 18:33
Show Gist options
  • Save zmij/7b491e104b0a3bdf1c62 to your computer and use it in GitHub Desktop.
Save zmij/7b491e104b0a3bdf1c62 to your computer and use it in GitHub Desktop.
MonoTouch extension method to obtain a UIViewController from a UIView
public static class NameItAsYouLike {
public static UIViewController GetController(this UIView view)
{
UIResponder parent = view;
while (parent != null) {
parent = parent.NextResponder;
if (parent is UIViewController) {
return parent as UIViewController;
}
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment