【发布时间】:2015-10-29 17:20:54
【问题描述】:
@IBAction func topButton(sender: AnyObject) {
let nicebutton = sender as! UIButton
nicebutton.enabled = false
let nopebutton = nicebutton.superview?.viewWithTag(102) as! UIButton
nopebutton.enabled = true
let hitPoint = sender.convertPoint(CGPointZero, toView: self.tableView)
let hitIndex = self.tableView.indexPathForRowAtPoint(hitPoint)
let object = objectAtIndexPath(hitIndex)
object.incrementKey("count")
self.tableView.reloadRowsAtIndexPaths([hitIndex!], withRowAnimation: UITableViewRowAnimation.Automatic)
object.saveInBackground()
}
@IBAction func bottomButton(sender: AnyObject) {
let nopebutton = sender as! UIButton
nopebutton.enabled = false
let nicebutton = nopebutton.superview?.viewWithTag(101) as! UIButton
nicebutton.enabled = true
let hitPoint = sender.convertPoint(CGPointZero, toView: self.tableView)
let hitIndex = self.tableView.indexPathForRowAtPoint(hitPoint)
let object = objectAtIndexPath(hitIndex)
object.incrementKey("count", byAmount: -1)
self.tableView.reloadRowsAtIndexPaths([hitIndex!], withRowAnimation: UITableViewRowAnimation.Automatic)
object.saveInBackground()
我已经尝试更改标签以查看是否是原因,但遗憾的是,这并没有起到太大作用。这似乎正在发生,这很奇怪。当然我宁愿一键禁用。
编辑 - 标签
【问题讨论】:
-
如果
topButton由带有标签 101 的按钮调用,bottomButton由带有标签 102 的按钮调用,则此设置适用于我。您是否 100% 确定您的标签和 IBAction 已挂钩正确吗? -
您在使用 TouchUpInside 吗?也许另一种事件类型在您的场景中效果更好,您可以尝试 TouchDown... 似乎适用于 stackoverflow.com/questions/10101253/…
-
@SteveWilford 我相信是这样,请注意更新后的帖子。
-
@NullPointer 我想我可能必须尝试一下。