teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

4

訂正

2020/04/18 02:48

投稿

退会済みユーザー
answer CHANGED
@@ -24,5 +24,11 @@
24
24
  }
25
25
  ```
26
26
 
27
- 画像を見るにセルが無いように見えますし、`UITableViewDetaSource`の必須メソッドが書いてないですが、
27
+ ~~画像を見るにセルが無いように見えますし、`UITableViewDetaSource`の必須メソッドが書いてないですが、
28
- 削除以外はテーブルビューがきちんと機能した上での質問なのでしょうか?
28
+ 削除以外はテーブルビューがきちんと機能した上での質問なのでしょうか?~~
29
+
30
+ ---
31
+
32
+ 質問が編集されたので追記します
33
+
34
+ [tableView(_:numberOfRowsInSection:)](https://developer.apple.com/documentation/uikit/uitableviewdatasource/1614931-tableview)の中でセルの数が固定となっています。可変するデータの個数を返してあげてください。

3

訂正

2020/04/18 02:48

投稿

退会済みユーザー
answer CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  ```swift
18
18
  func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
19
- print("セルの数: (tableView.numberOfRows(inSection: 0))"
19
+ print("セルの数: (tableView.numberOfRows(inSection: 0)")
20
20
  if editingStyle == UITableViewCell.EditingStyle.delete{
21
21
  memoList.remove(at : indexPath.row)
22
22
  tableView.deleteRows(at : [indexPath], with: .automatic)

2

訂正します。

2020/04/18 01:36

投稿

退会済みユーザー
answer CHANGED
@@ -6,4 +6,23 @@
6
6
  tableView.deleteRows(at : indexPath, with: .automatic)
7
7
  }
8
8
  ```
9
- なんじゃないの?
9
+ なんじゃないの?
10
+
11
+ ---
12
+
13
+ 質問が編集されたので、回答編集します。
14
+
15
+ [tableView(_:editingStyleForRowAt:)](https://developer.apple.com/documentation/uikit/uitableviewdelegate/1614869-tableview)の中を↓に書き換えて実行するとコンソールになんと表示されますか?
16
+
17
+ ```swift
18
+ func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
19
+ print("セルの数: (tableView.numberOfRows(inSection: 0))"
20
+ if editingStyle == UITableViewCell.EditingStyle.delete{
21
+ memoList.remove(at : indexPath.row)
22
+ tableView.deleteRows(at : [indexPath], with: .automatic)
23
+ }
24
+ }
25
+ ```
26
+
27
+ 画像を見るにセルが無いように見えますし、`UITableViewDetaSource`の必須メソッドが書いてないですが、
28
+ 削除以外はテーブルビューがきちんと機能した上での質問なのでしょうか?

1

訂正

2020/04/18 01:35

投稿

退会済みユーザー
answer CHANGED
@@ -1,6 +1,7 @@
1
1
  tableView editingStyleのなかで
2
2
 
3
+ ```swift
3
- ```swiftif editingStyle == UITableViewCell.EditingStyle.delete{
4
+ if editingStyle == UITableViewCell.EditingStyle.delete{
4
5
  memoList.remove(at : indexPath.row)
5
6
  tableView.deleteRows(at : indexPath, with: .automatic)
6
7
  }