In my app i want hide keyboard when i start scrolling UITableView. I search about this in internet, and most answer is subclassing UITableView (http://stackoverflow.com/ques
Here is the cleanest way to achieve this in iOS 7.0 and above:
tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
Or to dismiss interactively when touching:
tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive;
Or in Swift:
tableView.keyboardDismissMode = .onDrag
To dismiss interactively:
tableView.keyboardDismissMode = .interactive
After iOS 7, you can simple use the tableview property
Swift 3.0+
myTableView.keyboardDismissMode = UIScrollViewKeyboardDismissMode.OnDrag
ObjectiveC
myTableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
For earlier versions, implementing the scroll view delegate could work.
func scrollViewDidScroll(_ scrollView: UIScrollView) {
view.endEditing(true)
}