在我问这个之前我尝试其他解决方案,但它没有用
这是我的代码
override func viewDidLoad() { super.viewDidLoad() let tapGesture = UITapGestureRecognizer(target: self,action: "didTouchBoard:") view.addGestureRecognizer(tapGesture) tapGesture.cancelsTouchesInView = true }
当我点击任何地方它会隐藏键盘,如果存在,但如果我点击tableviewcell或collectionviewcell,它将不会点击
我试试这个tapGesture.cancelsTouchesInView,但不行
解决方法
如果希望表视图接收触摸,则更改tapGesture.cancelsTouchesInView
tapGesture.cancelsTouchesInView = false