Created
March 11, 2015 18:33
-
-
Save zmij/7b491e104b0a3bdf1c62 to your computer and use it in GitHub Desktop.
MonoTouch extension method to obtain a UIViewController from a UIView
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
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