I have the following code to display the images:
_image = [[imagesModel alloc] initFromURLWithString:imageURL completion:^(id model, JSONModelError *err) {
int x = 0;
int w = 1;
for (imageModel *img in _image.Images)
{
NSString *picString = [NSString stringWithFormat:picURL, img.filename];
NSLog(@"Images: %@", picString);
UIImage *getImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:picString]]];
UIImageView *imageView2 = [[UIImageView alloc] initWithImage:getImage];
self.pictureScroll.contentSize = CGSizeMake(w * 123, 120);
imageView2.frame = CGRectMake(x * 123, 1, 120, 120);
x++;
w++;
[pictureScroll addSubview:imageView2];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected)];
singleTap.numberOfTapsRequired = 1;
[imageView2 setUserInteractionEnabled:YES];
[imageView2 addGestureRecognizer:singleTap];
clicked = img.filename;
// hide the loader view
}
[HUD hideUIBlockingIndicator];
}];
When the user clicks on an image I want the user to go to a new view where they can see the image full size (it's a thumbnail now).
I open a new view now, but it opens the last images (Dùh). Does anyone have any idea how to fix this, my brains are a mess at the moment :/
One day later I found the answer by myself here:
tap gesture recognizer - which object was tapped?
I added right below the int w = 0
in the for loop I added 2 lines of code
Now I get an int depending on wich item is clicked. I use this int to get a filename for an array.