UITableView에서 쓰여지는 메서드를 정리해보자!
override func numberOfSections(in tableView: UITableView) -> Int {
return
}
위에 return 1 을주는게 통상적이지만 return 3 을주게되면 아래와 같은 값이 표기가된다.
override func tableView(_ tableView: UITableView, numberOfRowsInSection section : Int) -> Int{
return
}
return 뒤에 보통 데이터의 배열이 존재하는경우 return dataArray.count 라고 처리를 하곤 함. (*실습에선 그렇게 많이했어.... ㅠㅠ)
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell tableView.dequeueReusableCell(withIdentifier: "표시할셀 이름", for: indexPath)
}
Main - TableViewController - cell의 identifier를 "naeCell"로 설정해주면 위에 "표시할셀 이름" = "naeCell" 이라고 표기해주면 되는거당
override func talbeView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String?
이건 사용안해봤는데 나중에 꺼내먹어봐야겠다.(아래와 비슷)
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String?
이건 사용안해봤는데 나중에 꺼내먹어봐야겠다.(위와비슷)
override func tableView(_ tableView: UITableView, canEditRowAt indexPath) -> Bool
나는 테이블뷰에서 안써본게 참 많구나..
override func tableView(_ tableView: UITableView, canMoveRowAt indexPatt: IndexPath) -> Bool
너두..
override func sectionIndexTitles(for tableView: UITableView) -> String?
override func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int
override func tableView(_ tableView: UITableView, commit edittingStyle: UITableViewCell.EditingStyle, forRowAt indexPath : IndexPath){
여기부분에 code를 커밋해줘야한다
}
지난번 교육에서는 이 메서드에서 Edit을 통해 삭제했을 때, 처리과정을 정의해줬었다!
override func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? {
return "바꿀이름"
}
바꿀이름을 "삭제"로 바꿔주면 삭제로 나오게 된다 ㅎㅎ
override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath, to destinationIndexPath: IndexPath)
빨리써보고알려줄게