0
테이블보기에 섹션을 삭제하거나 추가 할 수있는 권한을 부여하려고합니다. nib에서 사용자 정의 헤더보기를 작성하고 레이블과 두 개의 버튼을 추가했습니다. 문제는 삭제하거나 섹션을 추가 할 때 점을 연결할 수 없다는 것입니다. 이 지금까지 내 코드는 다음과 같습니다Custom header button을 사용하여 tableview에서 섹션을 수정 하시겠습니까?
//Setup Header
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: headerID) as! CustomHeader
//Configure header...
header.addBtn.addTarget(self, action:Selector(("add")), for: .touchUpInside)
header.addBtn.tag = section
switch section {
case 0:
header.sectionLBL.text = "Detail 1"
case 1:
header.sectionLBL.text = "Detail 2"
default:
break
}
return header
}
@IBAction func addButton(sender: UIButton) {
//Add section code here...
}
@IBAction func delete(sender:UIButton){
//delete section code here...
}
나는 또한 내가 버튼을 사용하여 작업 할 수있는 커밋 스타일을 얻을 것입니다 방법을 알아 내려고 노력했다 : 당신은 스토리 보드 장면이나 펜촉을 연결할 수 있습니다
//Setup Editing Style for table view
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
//Editing styles for deletion or insertion...
}