https://www.apple.com/my/swift/

Hide keyboard when tap anywhere on UITableView

1
2
3
4
5
6
7
8
9
let tap = UITapGestureRecognizer(target: self, action: Selector("tableViewTapped:"))
// if this doesn't set to `false`, the table view cell won't takes any effect on tap
tap.cancelsTouchesInView = false
self.tableView.addGestureRecognizer(tap)

// ...
func tableViewTapped(sender: UITapGestureRecognizer) {
self.view.endEditing(true) // hide keyboard
}
Reference:

UITableViewCell dynamic height for auto-layout subviews

1
2
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.estimatedRowHeight = 44.0
Reference: