在这里,当按钮点击标签计数是递增时& decrements.While标签计数增量图像将由相应的count.here添加我的用于递增标签计数的代码
if (counter >= 9 )
return;
[_count setText:[NSString stringWithFormat:@"%d",++counter]];但是我需要在增加标签计数的同时显示,然后通过one.like自动增加图像

你能帮我实现吗,谢谢。
发布于 2016-01-18 13:00:03
在要显示图像的位置添加一个UIScrollView。单击“+”按钮时,通过传递“计数器”值调用以下方法。
-(void)addImage:(int) count {
UIScrollView * scView = [[UIScrollView alloc] init];
scView.frame = CGRectMake(30, 60, self.view.frame.size.width, 60);
UIButton * btn;
UIImageView * imgV;
float imgWidth = 44;
for(int i=0;i<count;i++) {
imgV = [[UIImageView alloc] init];
imgV.frame = CGRectMake(i*imgWidth, 0, imgWidth, 44);
imgV.image = [UIImage imageNamed:@"gitar"];
[scView addSubview:imgV];
}
[scView setContentSize:CGSizeMake(imgWidth*count, 50)];
[scView setBackgroundColor:[UIColor redColor]];
[self.view addSubview:scView];
}
- (IBAction)descrese:(id)sender {
counter -= 1;
[self addImage:counter];
}
- (IBAction)btnTap:(id)sender {
counter += 1;
[self addImage:counter];
}这会在水平滚动视图中添加任意数量的图像。
发布于 2016-01-18 12:48:34
使用带有图像单元格的uiscrollview,就这么简单。
发布于 2016-01-18 13:02:50
使用UIScrollView。随着元素数量的增加/减少:( 1)增加/减少UIScrollView大小;( 2)添加/删除元素
https://stackoverflow.com/questions/34854980
复制相似问题