2012-03-09 17 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

関連する問題