Search code examples
swiftuitableviewparametersuitapgesturerecognizer

I have a UItableView cell with a Image but can't get a image click to allow parameters


I have a EDIT2 UItableView, in Swift, with the normal labels and relevant Information. I have added a Image to the cell and all is working except when I click on the image I would like to open another ViewController with that particular cells relevant information. I have used:

     let popup: UITapGestureRecognizer   = UITapGestureRecognizer(target: self, action: #selector(self.popupalrmcontrnt))
     cell.alrmwarning.addGestureRecognizer(popup);

as the means for calling the pushViewController function, But the Viewcontoller requires a parameter AlarmID to be set Beforehand. Said Viewcontroller needs AlarmID to fetch its relevant information.

Edit1 The parameter is dependant on the selected cell.


Solution

  • Better use UIButton. you can set image to the button as background image. Also you can pass relevant info as an object to the new ViewController.