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