If I use UITapGestureRecognizer, my UITableView objets does not get taps, but the recognizer works well.
Tap recognizer init:
let tap = UITapGestureRecognizer(target: self, action: #selector(tapBackground))
menuBackground?.addGestureRecognizer(tap)
Windows hierarchy:
menuBackground?.addSubview(menuWindow!)
menuWindow?.addSubview(menuList!)
It works well:
@objc func tapBackground(sender: UITapGestureRecognizer) {
let tapLocation = sender.location(in: menuBackground)
if !menuWindow!.frame.contains(tapLocation) {
closeMenu()
}
}
It works well if i do not use the tap recognizer, but if i use that, this function does nothing. Why?
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print( indexPath.row )
}