0
我正在开发一个应用程序。我需要在另一个UIImageView中显示9个UIImageView。如果我们单击任何图像,然后确定所选的UIImageView并更改所选UIImageView的图像。下一次也需要做同样的事情但我们需要有新的改变形象方面显示前一个选择图像我写的如何在另一个图像中显示多个图像。
for (int h=0; h<8; h++)
{
int x=[[questions.marker_left objectAtIndex:h] intValue];
int y=[[questions.marker_top objectAtIndex:h] intValue];
img3=[[UIImageView alloc]initWithFrame:CGRectMake(x,y, 30, 30)];
img3.userInteractionEnabled=YES;
img1.userInteractionEnabled=YES;
img3.tag=h;
//img2.backgroundColor=[UIColor greenColor];
img3.image=[UIImage imageNamed:@"PINpurple.png"];
tap5=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(calculate:)];
tap5.delegate=self;
[img3 addGestureRecognizer:tap5];
[img1 addSubview:img3];
}
-(void)calculate:(UITapGestureRecognizer*)recognizer
{
NSInteger i=(recognizer).view.tag;
NSString *str=[questions.result objectAtIndex:i];
NSLog(@"%@",str);
if([str isEqualToString:@"true"])
{
img3.image=[UIImage imageNamed:@"PINgreen.png"];
}
else
{
img3.image=[UIImage imageNamed:@"PINred.png"];
}
}
选定的图像将被改变,但在选择下一个UIImageView.So后以前的UIImageView会得到旧的图像的代码,请帮助我,如何做到这一点?
我也做了同样的事情,但只有选定的图像将被改变。以前的imageview会得到以前的图像。 – Venkat1282 2012-04-05 10:15:14
@ user1294652,需要对您的问题进行一些编辑。请重新检查您的具体要求。所以任何人都可以轻松理解。 – Hemang 2012-04-05 10:16:38