ios - Add tapGesture to tableView then can not perform tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) method -


as know, use below code can endediting searchbar's firstresponder, if there scrollview or tableview, effect different.

override func touchesbegan(_ touches: set<uitouch>, event: uievent?) {     super.touchesbegan(touches, with: event)      self.view.endediting(true) } 

i add tapgesture tableview, can endediting searchbar's firstresponder.

but after add tapgesture tableview, tableview's tableview(_ tableview: uitableview, didselectrowat indexpath: indexpath) function not work more.

how can solve issue?


addition

my useful code below:

let tap:uitapgesturerecognizer = uitapgesturerecognizer.init(target: self, action: #selector(taptableview)) self.tableview.addgesturerecognizer(tap)   func taptableview() {      self.searchbar.endediting(true) } 

add tapgesture on view not on tableview

let tap:uitapgesturerecognizer = uitapgesturerecognizer.init(target: self, action: #selector(taptableview)) self.view.addgesturerecognizer(tap) 

Comments

Popular posts from this blog

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -