Created
March 11, 2013 09:12
-
-
Save helloworld116/5132960 to your computer and use it in GitHub Desktop.
ios:UIView查找所属的UIViewController
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
| //UIView获取所属的UIViewController范例 | |
| -(BookDetailViewController *)viewController{ | |
| for (UIView *next = [self superview]; next; next = [next superview]) { | |
| UIResponder *nextResponder = [next nextResponder]; | |
| if ([nextResponder isKindOfClass:[BookDetailViewController class]]) { | |
| return (BookDetailViewController *)nextResponder; | |
| } | |
| } | |
| return nil; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment