ios - How to dismiss keyboard in a tableView after typing in textview -
in app have uitableview
, includes in first cell uitextview
, in other cells uilabel
s.
how can dismiss keyboard after typing in uitableview
? want dismiss anytime tap on other cells or scroll tableview.
you can use uitableviewdelegate
conforms uiscrollviewdelegate
implement:
func scrollviewwillbegindragging(scrollview: uiscrollview) { dismisskeyboard() } func dismisskeyboard(){ self.view.endediting(true) } //add viewdidload: var tapgesture = uitapgesturerecognizer(target: self, action: "dismisskeyboard") tableview.addgesturerecognizer(tapgesture) //or since wanted dismiss when cell selected use: func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath){ dismisskeyboard() }
Comments
Post a Comment