[英]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.