回答編集履歴
3
修正
answer
CHANGED
@@ -25,4 +25,24 @@
|
|
25
25
|
dataArrayGroup.remove(at: 0)
|
26
26
|
tableView.deleteSections(IndexSet(integer: 0), with: .automatic)
|
27
27
|
}
|
28
|
+
```
|
29
|
+
|
30
|
+
---
|
31
|
+
`TextField`に入力した文字列と同じsectionを削除する場合以下の様に書いてください。
|
32
|
+
|
33
|
+
```swift
|
34
|
+
@IBAction func deleteSection(_ sender: UIButton) {
|
35
|
+
|
36
|
+
guard let text = textField.text,
|
37
|
+
!text.isEmpty,
|
38
|
+
!sectionTitleArray.isEmpty,
|
39
|
+
let indext = sectionTitleArray.index(of: text) else {
|
40
|
+
return
|
41
|
+
}
|
42
|
+
|
43
|
+
sectionTitleArray.remove(at: indext)
|
44
|
+
dataArrayGroup.remove(at: indext)
|
45
|
+
tableView.deleteSections(IndexSet(integer: indext), with: .automatic)
|
46
|
+
|
47
|
+
}
|
28
48
|
```
|
2
修正
answer
CHANGED
@@ -7,4 +7,22 @@
|
|
7
7
|
tableView.deleteRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
|
8
8
|
}
|
9
9
|
}
|
10
|
+
```
|
11
|
+
---
|
12
|
+
`section`の削除
|
13
|
+
|
14
|
+
ボタンを何処かに追加して以下のメソッドとひも付けてください。
|
15
|
+
※とりあえず決め打ちで0番目の`section`を削除しています。
|
16
|
+
|
17
|
+
```swift
|
18
|
+
@IBAction func deleteSection(_ sender: UIButton) {
|
19
|
+
|
20
|
+
if sectionTitleArray.isEmpty {
|
21
|
+
return
|
22
|
+
}
|
23
|
+
|
24
|
+
sectionTitleArray.remove(at: 0)
|
25
|
+
dataArrayGroup.remove(at: 0)
|
26
|
+
tableView.deleteSections(IndexSet(integer: 0), with: .automatic)
|
27
|
+
}
|
10
28
|
```
|
1
修正
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
以下の部分のみ書き換える事で
|
1
|
+
`row`の削除に関しては以下の部分のみ書き換える事でできますよ。
|
2
2
|
|
3
3
|
```swift
|
4
4
|
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
|