【发布时间】:2015-03-15 02:42:03
【问题描述】:
我的表格视图有问题,我可以很好地点击我的单元格。但是如果我快速点击同一个单元格两次。它运行“didSelectRowAtIndexPath”两次。在我的导航控制器堆栈中添加 2 个相同的视图
函数如下:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var VC = detaiLSuggestion_VC()
self.navigationController?.pushViewController(VC, animated: true)
var selectedCell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)!
if selectedCell.backgroundColor == UIColor.formulaFormColor() {
println("Buy Action")
selectedCell.backgroundColor = UIColor.formulaMediumBlue()
UIView.animateWithDuration(0.5, animations: {
selectedCell.backgroundColor = UIColor.formulaFormColor()
})
} else {
println("Sell Action")
selectedCell.backgroundColor = UIColor.formulaGreenColor()
UIView.animateWithDuration(0.5, animations: {
selectedCell.backgroundColor = UIColor.formulaLightGreenColor()
})
}
为什么我可以选择同一个单元格两次?我将如何解决这个问题?
【问题讨论】:
标签: ios uitableview swift didselectrowatindexpath tableviewcell