Okay well I have made a couple threads asking how to display images randomly/pick a random image. What I have came to realize is that I do not know how to combine these two methods together.
I have 5 images in an array.
My .h file:
@property (strong, nonatomic) NSArray *imageArray;
My .m file:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
UIImage *image1 = [UIImage imageNamed:@"image-1.png"];
UIImage *image2 = [UIImage imageNamed:@"image-2.png"];
UIImage *image3 = [UIImage imageNamed:@"image-3.png"];
UIImage *image4 = [UIImage imageNamed:@"image-4.png"];
UIImage *image5 = [UIImage imageNamed:@"image-5.png"];
_imageArray = @[image1, image2, image3, image4, image5];
}
This is what I have right now, I have been playing around with other code ive found elsewhere but have had no success so left it out.
Now that you see what I have, this is what im trying to do:
I need to use a method that will pick one of my 5 images randomly from my array and then display it in a random position in my view.
I also need to repeat this loop, but with constraints. I need each image to have a "value" such as: image-1 equal to 1, image-2 equal to 2, image-3 equal to 3, image-4 equal to 4, and image-5 equal to 5. And have the loop repeat until the images displayed equals a total value of 50.
Im not really sure where to begin on what methods to use. Im sure picking and displaying randomly is easy to some of you but the values and repeating until equaling 50 seems complex. So any and all help is greatly appreciated! Thanks in advance to anyone who can help, im new to coding so if you can explain why you used your code it would help even more! Thanks!
Edit: This guy tried helping me in my other thread adding the whole picking a random image as well. His response is here: How to display multiple UIImageViews and I used his code but nothing happened. I am not sure if his code is wrong somewhere or if I did something wrong.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…