画像ジェネレーターを作成したいのですが、どこでも見つけることができるのはランダムなものだけですが、特定の順序である必要があります。
これが私が持っているものですが、画像をランダムな順序にしたくありません:
.h ファイル
@interface ViewController :UIViewController {
IBOutlet UIImageView *imageview;
IBOutlet UIImageView *imageview2;
}
-(IBAction)randomimagebutton;
-(IBAction)randomimagebutton2;
@end
.m ファイル
-(IBAction)randomimagebutton {
int randomimages = rand() % 8;
switch (randomimages) {
case 0:
imageview.image = [UIImage imageNamed:@"eye right wihte.png"];
break;
case 1:
imageview.image = [UIImage imageNamed:@"eye right red.png"];
break;
case 2:
imageview.image = [UIImage imageNamed:@"eye right pink.png"];
break;
case 3:
imageview.image = [UIImage imageNamed:@"eye right light blue.png"];
break;
case 4:
imageview.image = [UIImage imageNamed:@"eye right dark blue.png"];
break;
case 5:
imageview.image = [UIImage imageNamed:@"eye right light green.png"];
break;
case 6:
imageview.image = [UIImage imageNamed:@"eye right dark green.png"];
break;
case 7:
imageview.image = [UIImage imageNamed:@"eye right orange.png"];
break;
case 8:
imageview.image = [UIImage imageNamed:@"eye right yellow.png"];
break;
default:
break;
}
}
-(IBAction)randomimagebutton2 {
int randomimages = rand() % 8;
switch (randomimages) {
case 0:
imageview2.image = [UIImage imageNamed:@"eye left white.png"];
break;
case 1:
imageview2.image = [UIImage imageNamed:@"eye left red.png"];
break;
case 2:
imageview2.image = [UIImage imageNamed:@"eye left pink.png"];
break;
case 3:
imageview2.image = [UIImage imageNamed:@"eye left light blue.png"];
break;
case 4:
imageview2.image = [UIImage imageNamed:@"eye left dark blue.png"];
break;
case 5:
imageview2.image = [UIImage imageNamed:@"eye left light green.png"];
break;
case 6:
imageview2.image = [UIImage imageNamed:@"eye left dark green.png"];
break;
case 7:
imageview2.image = [UIImage imageNamed:@"eye left orange.png"];
break;
case 8:
imageview2.image = [UIImage imageNamed:@"eye left yellow.png"];
break;
default:
break;
}
}