This is for a monotouch (Xamarin Studio) iPad app
I have a survey that asks the user to look at an image and rate it, there are 140 images and they are shown randomly. I have these images in a folder and named them pic1.jpg, pic2.jpg, pic3.jpg, etc. At the start of the survey I randomly generate an array of numbers from 1-140, making sure NOT to have the same number twice (This is verified and is working....). I then go through the array and show the images in the random order.
After the update of iOS7 I am having an issues with the wrong image showing up. It will show up multiple times in one test. I have debugged this and it is simply the wrong image that is showing up, almost as if the image has been replaced by another image... For example when image 81 should have showed up image 94 actually did. This happened 12 times in the 140 images...
Here is the code for the rating:
public override void ViewDidLoad ()
{
int[] Num2 = new int[141]; //array for random numbers
int ic = 0; //int count
rand2(ref Num2); //routine to generate random numbers...
this.btnSEG.ValueChanged += delegate(object sender, EventArgs e){ //submit the rating
ic = ic + 1; //increase the count
imgSorce.Image.Dispose(); //clear the current image
using (var pool = new NSAutoreleasePool ()) { //put this in to prevent leaks
this.imgSorce.Image = UIImage.FromFile ("image/pic" + Num2[ic] + ".jpg"); //display the next image
};
};
I have checked all the images in the image folder and there are not any duplicates.
Any ideas why this would be happening?
Updated
@Krumelur asked for the code to generate the random numbered array... Here it is...
private void rand2 (ref int[] rn)
{
int i = 0;
int icount = 0;
for (i = 0; i <= 139;)
{
int n = 0;
rand3(ref n);
for(icount = 0; icount <= 139;)
{
if (n == rn[icount])
{
icount = 141;
}
icount = icount + 1;
if (icount == 140)
{
rn[i] = n;
i = i+1;
}
}
};
rn[140] = 0;
}
And here is rand3 that was referenced above...
private void rand3 (ref int num)
{
Random r = new Random();
num = r.Next(1, 141);
}