Skip to content

Latest commit

 

History

History
32 lines (28 loc) · 893 Bytes

14. TableView 기본 삭제 기능.md

File metadata and controls

32 lines (28 loc) · 893 Bytes

날짜: 2023-05-15 18:38

주제: 개별삭제 기능


메모:

  • 스와이프로 삭제 기능 구현 방법
extension ViewController: UITableViewDelegate { 
	func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { 
		// 내부 데이터와 연동한 로직 구현  ex 
		if editingStyle == .delete { 
			if indexPath.sction == 0 { 
				data.remove(at: indexPath.row)
			} else { 
				testAppend.remove(at: indexPath.row)
			}
		}
		tableView.reloadData()
	}
}
  • 위와 다르게, edit 모드로 들어가서 삭제, 일괄 선택 및 삭제로 구현, custom swipe 버튼 구현 등 여러 방법으로 삭제 코드를 작성할 수 있다.

출처(참고문헌)

연결문서

  • [[1. UITableView]]
  • [[15. 스와이프 버튼 커스텀]]

Tag

  • #IOS/UITableView/Delegate