I have a button in a tableview cell. I want that initially the button has an image "A", when the user clicks on it, it changes to "B", when the user clicks on it again it changes back to "A".
Let the two images be "A" and "B" in this scenario
I am unable to use tag because I am using it to determine which button the user clicked using indexPath.row
below is the current state of my button function.
@IBAction func setNotification(sender: UIButton!) {
cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: sender.tag, inSection: 0)) as! CustomTableViewCell
sender.setImage(UIImage(named: "B")!, forState: .Normal)
currentRegion = CLCircularRegion(center: CLLocationCoordinate2D(latitude: latitude ,longitude:longitude), radius: 10, identifier: "xyz")
Also this is how my cellForRowAtIndexPathfunction looks
cell.notifybutton.addTarget(self, action: "setNotification:", forControlEvents: UIControlEvents.TouchUpInside)
cell.notifybutton.setImage(UIImage(named: "A"), forState: UIControlState.Normal)
cell.notifybutton.tag = indexPath.row