Display random image in UIImageView animation?

(NSArray *)shuffledArray { NSMutableArray *array = NSMutableArray arrayWithCapacity:self count; NSMutableArray *copy = self mutableCopy; while (copy count > 0) { int index = arc4random() % copy count; id objectToMove = copy objectAtIndex:index; array addObject:objectToMove; copy removeObjectAtIndex:index; } copy release; return array; } Try something like this.

People are remarkably good at seeing patterns. If you do want repetition, then at least base it on prime numbers, since those are much harder to spot. In any case, you could do this yourself simply by setting up a timer and randomly selecting a new image each time the timer ticks.

If you want to ensure you don't show the same image twice in a row, the simplest way is to just randomly pick an image from your array until you get a different one. If you want to ensure you show all 4 images before showing one of them twice, then randomly shuffle your array and take items off the front, then when you run out, shuffle it again (and to avoid the duplicate problem, just keep shuffling until the first entry in the array is different than the last entry in the previous array).

FinalArray would be random now... NSMutableArray *tempImages = NSMutableArray alloc initWithObjects: UIImage imageNamed:@"img1. Png", UIImage imageNamed:@"img2. Png", UIImage imageNamed:@"img3.

Png", UIImage imageNamed:@"img4. Png", nil; NSMutableArray *finalArray = NSMutableArray alloc init; int count = tempImages count; for (int I = 0; I.

This will crash.. Since you are removing objects from tempImages and your array will continue till your initial array count.. – Dimple Panchal Nov 19 at 6:44.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions