This question already has an answer here:
I'm trying to display a random image from 3 possible images. The problem when I try to load it in the simulator is it only seems to be displaying one of the three. In this scenario it's only showing case 1 every time.
{
int randomimages = rand() %3;
switch (randomimages) {
case 0:
Background.image = [UIImage imageNamed:@"BGK11.png"];
break;
case 1:
Background.image = [UIImage imageNamed:@"BGK12.png"];
break;
case 2:
Background.image = [UIImage imageNamed:@"BGK100.png"];
break;
}
i declared a IBOutlet UIImageView *Background; in the .h
Do I need to seed the integer differently? I'm not sure what is going wrong.
Aucun commentaire:
Enregistrer un commentaire