0
私はテーブルビューにセクションを削除または追加する機能を提供しようとしています。 nibでカスタムヘッダービューを作成し、ラベルと2つのボタンを追加しました。 問題は、削除またはセクションを追加する際にドットを接続できないということです。 これは、これまでの私のコードです:カスタムヘッダーボタンを使用して、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...
}