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
Post a Comment