출처 : http://stackoverflow.com/questions/1340434/get-to-uiviewcontroller-from-uiview-on-iphone


@interface
UIView (FindUIViewController)
- (UIViewController *) firstAvailableUIViewController;
- (id) traverseResponderChainForUIViewController;
@end

@implementation UIView (FindUIViewController)
- (UIViewController *) firstAvailableUIViewController {
   
// convenience function for casting and to "mask" the recursive function
   
return (UIViewController *)[self traverseResponderChainForUIViewController];
}

- (id) traverseResponderChainForUIViewController {
    id nextResponder
= [self nextResponder];
   
if ([nextResponder isKindOfClass:[UIViewController class]]) {
       
return nextResponder;
   
} else if ([nextResponder isKindOfClass:[UIView class]]) {
       
return [nextResponder traverseResponderChainForUIViewController];
   
} else {
       
return nil;
   
}
}
@end

Posted by incree

2012/03/10 16:29 2012/03/10 16:29
, ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/104

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다