【问题标题】:Get tag of images in scrollview获取滚动视图中的图像标签
【发布时间】:2012-03-09 03:21:00
【问题描述】:

我使用以下代码创建了一个滚动视图:

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];
}

如何获取视图中当前的图片标签?

【问题讨论】:

    标签: ios uiscrollview tags


    【解决方案1】:

    你可以通过获取bigScrollView的所有子视图来获取标签。

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

    【讨论】:

    • 谢谢。但是如何获取视图中显示的 current 子视图的标签?
    猜你喜欢
    • 2013-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 2012-01-05
    • 1970-01-01
    相关资源
    最近更新 更多