iOS UITableViewCellで選択されたCellをもとに戻す
English version below.
はじめに
選択されたCellをもとに戻す。よくやることですが、恥ずかしながら勘違いして覚えていたので備忘録。
解決方法
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { //Change the selected background view of the cell. tableView.deselectRow(at: indexPath, animated: true) }
おまけ
はじめに次のようにして非選択すると覚えていました。
let cell = tableView.cellForRow(at: indexPath) cell.(SOMETHING)
当然ながら(SOMETHING)メソッドは見つかりませんでした;) cellに対して、非選択にするわけではないので注意しましょう。