마지막부분 checkmark 부분 답안 코드 좀 알 수 있을까요?

guinness987 2023년 1월 17일 AM 02:14 33 0
guinness987 Profile Image Level 3

didDeselectRowAt으로 선택해제된 셀 아이템의 on값을 false로 주고 accessoryType을 none으로 주는 코드까진 했는데 이게 처음 checkmark가 되어 있는 첫번째 로우를 클릭하거나 두개의 셀을 한번씩 다 누르고 나서야 토글이 됩니다

extension MultiSectionTableViewViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section == 3 && indexPath.row == 0 {
showActionSheet()

tableView.deselectRow(at: indexPath, animated:true)
}

if indexPath.section == 4 {
if let cell = tableView.cellForRow(at: indexPath) {
list[indexPath.section].items[indexPath.row].on =true
cell.accessoryType = .checkmark
}
}
}

func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
if indexPath.section == 4 {
if let cell = tableView.cellForRow(at: indexPath) {
list[indexPath.section].items[indexPath.row].on =false
cell.accessoryType = .none
}
}
}
}


댓글 쓰기
답변하기
마크다운이 처음이라면 [마크다운 설명서]를 확인해 보세요.