I'm trying to have a random image display when the view loads.
I can get an image to display but its not random, it comes up as the position of the %.
For example, this code displays the 4th image all the time.
Here is my code.
{
[super viewDidLoad];
int randomImages = rand() % 4;
switch (randomImages) {
case 0:
_imageView.image = [UIImage imageNamed:@"1.png"];
break;
case 1:
_imageView.image = [UIImage imageNamed:@"2.png"];
break;
case 2:
_imageView.image = [UIImage imageNamed:@"3.png"];
break;
case 3:
_imageView.image = [UIImage imageNamed:@"4.png"];
break;
}
}
Anyone know what I'm doing wrong?