【发布时间】:2019-07-26 01:21:55
【问题描述】:
如果我使用 UITapGestureRecognizer,我的 UITableView 对象不会被点击,但识别器运行良好。
点击识别器初始化:
let tap = UITapGestureRecognizer(target: self, action: #selector(tapBackground))
menuBackground?.addGestureRecognizer(tap)
Windows 层次结构:
menuBackground?.addSubview(menuWindow!)
menuWindow?.addSubview(menuList!)
效果很好:
@objc func tapBackground(sender: UITapGestureRecognizer) {
let tapLocation = sender.location(in: menuBackground)
if !menuWindow!.frame.contains(tapLocation) {
closeMenu()
}
}
如果我不使用点击识别器,它工作得很好,但如果我使用它,这个函数什么都不做。为什么?
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print( indexPath.row )
}
【问题讨论】:
标签: swift uitableview uitapgesturerecognizer