Created
March 17, 2014 14:24
-
-
Save DanLuchi/9600114 to your computer and use it in GitHub Desktop.
uiview_helper.rb
This file contains hidden or 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
class UIView | |
def controller | |
controller_for_view(self) | |
end | |
def controller_for_view(view) | |
controller = UIViewController.viewControllerForView view | |
if controller | |
controller | |
elsif view.superview | |
controller_for_view view.superview | |
else | |
nil | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment