[英]Get tag of images in 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];
}
如何獲取視圖中當前圖像的標簽?
您可以通過獲取bigScrollView的所有子視圖來獲取標簽。
for(UIView *subview in [bigScrollView subviews])
{
if([subview isKindOfClass:[UIImageView class]])
{
NSLog("%d",[subview tag]);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.