【发布时间】:2017-01-26 06:38:42
【问题描述】:
我有一个点击手势识别器,用于关闭键盘并存储来自文本字段的一些数据。在同一个视图上,我有一个带有 didSelectRowAtIndexPath 的 tableview。当我点击一行时,我的手势识别器被调用而不是 uitableview 方法。我搜索了堆栈溢出并找到了一些我尝试实现的 obj c 解决方案。解决方案是实现cancelsTouchesInView并将其设置为NO。下面是我的点击手势识别器功能,它似乎不起作用。我是不是做错了什么?
func addTapGestureRecognizer(){
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(detailViewController.dismissKeyboard))
self.view.addGestureRecognizer(tap)
tap.cancelsTouchesInView = false;
}
这是我的 didSelectRowAtIndexPath
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("Stisnut Redak")
let selectedRowObject = arrayForSteps[indexPath.row]
if selectedRowObject.status == false {
tableView.cellForRowAtIndexPath(indexPath)?.accessoryType = .None
} else {
tableView.cellForRowAtIndexPath(indexPath)?.accessoryType = .Checkmark
}
}
【问题讨论】:
标签: ios swift uitableview uitapgesturerecognizer