今回の内容
-
.accessoryType
を用いてTableViewのCellにチェックマークなどを表示する。
コードと簡単解説
.accessoryType = .checkmark

-
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {}
内でindexPathからタップされたCellを取得します。 -
cell?.accessoryType = .checkmark
でタップされたCellにチェックマークを表示します。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = .checkmark //チェックマーク
}
.accessoryType = .detailButton

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = .detailButton
}
.accessoryType = .disclosureIndicator

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = .disclosureIndicator
}
.accessoryType = .detailDisclosureButton

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = .detailDisclosureButton
}
終わり
ご指摘、ご質問などありましたら、コメントまでお願い致します。