I have a tableView, and inside of that tableView are 3 images.
I would like to be able to select an image and be directed to another VC where it displays the image that has been tapped.
For my images (downloaded from Parse) I have a uuid (unique identifier), before when I was using a collectionView I set it up like this:
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
postuuid.append(uuidArray[indexPath.row])
let post = self.storyboard?.instantiateViewControllerWithIdentifier("collectionImage") as! CollectionImageViewController
self.navigationController?.pushViewController(post, animated: true)
}
And that got me what I am trying to achieve now...
I realized I cannot use TableView SelectedRow..... as that would select the entire row obviously, so I have set up a image UITapGestureRecognized like so:
let imageTap = UITapGestureRecognizer(target: self, action: "imageTap")
imageTap.numberOfTapsRequired = 1
imageView.userInteractionEnabled = true
imageView.addGestureRecognizer(imageTap)
And then a func() to redirect it to a new VC:
func imageTap() {
postuuid.append// My issues here, I'm not sure how to set it up or reference it to the cellForRow, like I did it in the collectionViewSelected item code above.
let post = self.storyboard?.instantiateViewControllerWithIdentifier("collectionImage") as! CollectionImageViewController
self.navigationController?.pushViewController(post, animated: true)
}
As you'll see from my code I do not know, or can't seem to figure it out at the moment, how to connect it to the unique ID...
I have the UUID set up as var = uuidArray = String which is downloading them correctly...
CellForRow...:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
var counter = (indexPath.row * 3)
let cell = tableView.dequeueReusableCellWithIdentifier("cell") as! ProfileTableViewCell
for imageView in cell.threeImages {
imageView.image = UIImage(named: "ImagePlaceHolder")
if counter < imageArray.count {
imageView.hidden = false
let finalImage = imageArray[counter++]["image"]
finalImage!.getDataInBackgroundWithBlock {
(imageData: NSData?, error: NSError?) -> Void in
if error == nil {
if let imageData = imageData {
imageView.image = UIImage(data:imageData)
}}}} else {
imageView.hidden = true
}
let imageTap = UITapGestureRecognizer(target: self, action: "imageTap")
imageTap.numberOfTapsRequired = 1
imageView.userInteractionEnabled = true
imageView.addGestureRecognizer(imageTap)
return cell
}
If anyone can help me with this issue, I thank you very much in advance!
Best regards.