ビューには 8 つの UIImageView があり、すべて.handで宣言されてい.mます。
私はそれらを呼んだimg01、、、img02... img03、img08
01.png、02.png、03.png、...という名前の 8 枚の写真もあります08.png。
最初の写真を最初の写真に設定したい場合はimageView、次のコマンドを使用します。
UIImage *image = [UIImage imageNamed:@"01.png"];
[img01 setImage:image];
UIImageViewsとpicsがたくさんある場合はどうなりますか?
このコードを使用しようとしましたが、コードの最後の行を実行する方法がわかりませんでした。
int count = 1;
while (count <= 8) {
NSString *countString = [[NSString alloc]initWithFormat:@"%i", count];
NSString *picname = [NSString stringWithFormat:@"0%@.png", countString];
NSString *imgName = [NSString stringWithFormat:@"img0%@", countString];
UIImage *image = [UIImage imageNamed:picname];
[img01 setImage:image];
count++;
}
コードは最初の imageView のみを変更します。すべてを変更する必要がありimageViewsます。