ios - How to dismiss keyboard in a tableView after typing in textview -


in app have uitableview, includes in first cell uitextview , in other cells uilabels.

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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -