我有 5 个UIImageView
标签,标签为 100、101、102、103、104。
我想让它们在用户验证练习时出现。因此,如果验证了 1 个练习UIImageView
,将出现带有标签 100 的练习。如果验证了 2 个练习,那么UIImageView
标签 100 和 101 都会出现,依此类推。我尝试了下面的代码,但只出现了一张图像。为什么?我怎样才能解决这个问题?
for (int j = 0; j < 5; j++) {
UIImageView *coin = (UIImageView *)[self.view viewWithTag:100+j];
NSLog(@"coin.x: %f, coin.y: %f", coin.frame.origin.x, coin.frame.origin.y);
NSLog(@"cointag = %d", coin.tag);
if (j < library.themesCompleted)
{
NSLog(@"HIDDEN = NO");
coin.hidden = NO;
}
else
{
NSLog(@"HIDDEN = YES");
coin.hidden = YES;
}
}
这出现在日志中:
2012-06-27 18:24:06.463 test[4499:1da07] coin.x: 77.000000, coin.y: 1.000000
2012-06-27 18:24:06.463 test[4499:1da07] cointag = 100
2012-06-27 18:24:06.463 test[4499:1da07] HIDDEN = NO
2012-06-27 18:24:06.464 test[4499:1da07] coin.x: 92.000000, coin.y: 1.000000
2012-06-27 18:24:06.464 test[4499:1da07] cointag = 101
2012-06-27 18:24:06.464 test[4499:1da07] HIDDEN = NO
2012-06-27 18:24:06.464 test[4499:1da07] coin.x: 107.000000, coin.y: 2.000000
2012-06-27 18:24:06.465 test[4499:1da07] cointag = 102
2012-06-27 18:24:06.465 test[4499:1da07] HIDDEN = YES
2012-06-27 18:24:06.465 test[4499:1da07] coin.x: 122.000000, coin.y: 1.000000
2012-06-27 18:24:06.465 test[4499:1da07] cointag = 103
2012-06-27 18:24:06.466 test[4499:1da07] HIDDEN = YES
2012-06-27 18:24:06.466 test[4499:1da07] coin.x: 136.000000, coin.y: 1.000000
2012-06-27 18:24:06.466 test[4499:1da07] cointag = 104
2012-06-27 18:24:06.466 test[4499:1da07] HIDDEN = YES