2013-02-03 3 views
-2

여러분 중 누구라도 뷰에서 하위 뷰 목록을 가져올 수 있습니다. 목록을 배열로 가져 오는 방법이 있습니까?어떻게 하위보기 목록을 볼 수 있습니까?

NSMutableArray *subviews= .... //all my subviews 
+2

당신은 수동 ... [UIView의 클래스 참조] (http://developer.apple을 읽어야 .com/library/ios/# documentation/uikit/reference/uiview_class/UIView/UIView.html # // apple_ref/doc/uid/TP40006816-CH3-SW17) – poncha

답변

10

당신은

- (void)listSubviewsOfView:(UIView *)view { 

    // Get the subviews of the view 
    NSArray *subviews = [view subviews]; 

    // Return if there are no subviews 
    if ([subviews count] == 0) return; 

    for (UIView *subview in subviews) { 

     NSLog(@"%@", subview); 

     // List the subviews of subview 
     [self listSubviewsOfView:subview]; 
    } 
} 

이 링크를 통해 이동하십시오 이런 식으로 할 수 How to list out all the subviews in a uiviewcontroller in iOS?

관련 문제