It looks like you're new here. If you want to get involved, click one of these buttons!
for (m = 0; m <=29; m++)
{
rnd = arc4random_uniform(arr.count-m)+m;
NSString *imageName=[FrontsCards objectAtIndex:rnd];
fullImageName=[NSString stringWithFormat:@"%@",imageName];
int padding=0;
CGRect imageViewFrame=CGRectMake(scrollView.frame.size.width*m+padding, scrollView.frame.origin.y, scrollView.frame.size.width-2*padding, scrollView.frame.size.height);
ImgView=[[UIImageView alloc]initWithFrame:imageViewFrame];
[ImgView setImage:[UIImage imageNamed:fullImageName]];
[scrollView addSubview:ImgView];
[ImgView setAccessibilityIdentifier:[arr objectAtIndex:rnd]];
// Tap Gesture //
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapImgView:)];
doubleTap.numberOfTapsRequired = 2;
doubleTap.delegate = self;
[self.ImgView addGestureRecognizer:doubleTap];
[self.ImgView setImage:[UIImage imageNamed:fullImageName]];
NSLog(@"full image name %@",fullImageName);
NSLog(@"Image Name = %@", fullImageName);
[self.ImgView setTag:rnd];
self.ImgView.userInteractionEnabled=YES;
NSString *imageName1=[FrontsCards objectAtIndex:rnd];
[tweentyarray addObject:imageName1];
}
CGSize scrollViewSize=CGSizeMake(scrollView.frame.size.width*30, scrollView.frame.size.height);
[scrollView setContentSize:scrollViewSize];
[self.view addSubview:scrollView];
scrollView.delegate=self;
Replies
If you want random non-repeating, then make a mutable copy of your array. Each time you fetch a random object from the mutable array, remove it from the array. Then when the array is empty, re-fill it with the contents of the original array.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
I'm available for one-on-one help at CodeMentor