출처 : 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 : 이 글에는 트랙백을 보낼 수 없습니다


Notices

Archives

Authors

  1. incree

Recent Trackbacks

Calendar

«   2018/05   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Site Stats

Total hits:
461904
Today:
73
Yesterday:
196