I'm running into a weird issue with trying to disable a like button after it's been pressed. It's just a standard UIButton
in a UITableView
, and I have a similar set up in other screens of my app, and it works fine on those views. Anyways, on this particular view, when say, the top button, is pressed, I have a line of code in my topButton(sender: UIButton)
method that sets sender.enabled = false
When I watch the code execute in debug, the program hits this line and moves on like it worked fine, but the state of the button is never changed. It can be selected over and over again.
I also tried to set the state directly in the UITableViewCell
class, and the result is the same. I changed the alpha
value in that @IBAction
and that part worked, but the button was still enabled.
I can't seem to figure out why it's doing this! Can anyone else offer some help?
EDIT: Posted code, although I thought I had included enough
@IBAction func topButton(sender: UIButton!) {
sender.enabled = false
let hitPoint = sender.convertPoint(CGPointZero, toView: self.tableView)
let hitIndex = self.tableView.indexPathForRowAtPoint(hitPoint)
let object = objectAtIndexPath(hitIndex)
object.incrementKey("UpDown")
object.saveInBackground()
}
Note that I tried topButton(sender: UIButton)
and topButton(sender: UIButton!)
and it didn't change anything.
Like I mentioned, everything else in the method executes fine, the activity is saved in the database, but the button is not disabled.