2012-03-09 3 views
0

에 이미지 태그를 가져 오기 :내가있는 ScrollView 다음 코드를 사용하여 만든있는 ScrollView

NSUInteger i; 
for (i = 1; i <= kNumImages; i++) 
{ 
    imageName = [NSString stringWithFormat:image, i]; 
    UIImage *image = [UIImage imageNamed:imageName]; 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 

    CGRect rect = imageView.frame; 
    rect.size.height = kScrollObjHeight; 
    rect.size.width = kScrollObjWidth; 
    imageView.frame = rect; 
    imageView.tag = i; // tag our images for later use when we place them in serial fashion 
    [bigScrollView addSubview:imageView]; 
} 

가 어떻게 뷰의 이미지 의 태그 현재을 얻을 수 있습니까?

답변

1

bigScrollView의 모든 하위 뷰를 가져 와서 태그를 가져올 수 있습니다.

for(UIView *subview in [bigScrollView subviews]) 
{ 
    if([subview isKindOfClass:[UIImageView class]]) 
    { 
     NSLog("%d",[subview tag]); 
    } 
} 
+0

감사합니다. 하지만 어떻게 * 현재 * 하위 뷰의 태그가 뷰에 표시되게 할 수 있습니까? – benbeel